Page 125 - TP_Play_V2.1_class8
P. 125
Recap
Looping statements are very useful and necessary for developing applications.
The for statement executes a simple or compound statement for a fixed number of times.
The range() function is an in-built function of Python.
The while statement executes a set of statements repeatedly, until the logical expression
evaluates to true.
The break keyword in Python is used for bringing the program control out of the loop.
When a continue statement is encountered inside a loop, control of the program jumps
to the beginning of the loop for next iteration, skipping the execution of rest of the
statements of the loop for the current iteration.
Exercise
A. Tick ( ) the correct option.
1. Which of the following statements is used to repeat a set of instructions until a condition
evaluates to true?
a. while b. else
c. if d. None of these
2. Which of the following is a looping statement in Python?
a. while b. if
c. break d. All of these
3. Identify the statement that allows to repeat a task for a fixed number of times.
a. for b. if…else
c. continue d. All of these
4. ............................... is used for bringing the program control out of the loop.
a. if b. for
c. break d. while
B. Fill in the blanks using the words given below:
infinite, break, one, continue, non-zero, false
1. A single break statement will break out of only ............................... loop.
2. Any ............................... value in the while loop indicates an always true condition whereas zero
indicates ............................... condition.
Loops in Python 123

