Page 113 - modular4.0
P. 113
Chapter Profile
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, as long as the logical expression
evaluates to true.
The break keyword in Python is used for sending 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 statement executes for a fixed number of times?
a. break b. continue
c. while d. for
2. What does range(4,8) is equivalent to?
a. 4,5,6,7,8 b. 0,1,2,3,4
c. 4,5,6,7 d. 0,1,2,3,4,5,6,7
3. Choose the default value of step size in range() function.
a. 0 b. 1
c. 2 d. -1
4. What does the continue statement do in a loop?
a. Exit the loop b. Skip to the next iteration
c. Stop the program d. Restart the program
B. Fill in the blanks using the words given below:
Sequence, break, infinite loop, in-built
1. is a keyword in Python which is used for sending the program control out of the
loop.
2. Range() function is an function of Python.
3. A is a succession of values bound together by a single name.
4. loop never ends.
Loops in Python 111

