Page 53 - tp_Modula_v2.0
P. 53
A sequence is a succession of values bound together by a single name.
The while statement executes a set of statements repeatedly, until the logical expression
evaluates to true.
To come out of the infinite loop, we can either close the program window or press Ctrl + C.
The else block is executed when the condition given in the while statement becomes false.
The break is a keyword in Python which 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.
Exercise
A. Tick ( ) the correct option.
1. What while loop do?
a. Repeat a chunk of code a given number of times
b. Repeat a chunk of code until a condition is true
c. Repeat a chunk of code until a condition is false
d. Repeat a chunk of code indefinitely
2. Which of the following is a looping statement in Python?
a. for statement b. while statement
c. if statement d. break statement
3. Which of the following statements allow to repeat a task for a fixed number of times?
a. for statement b. while statement
c. if…else statement d. continue statement
4. Which of the following statements terminates the execution of the loop?
a. if b. for
c. break d. continue
B. Write 'T' for true and 'F' for false statements.
1. The range( ) function is used in the for loop to iterate over the numbers. ……………………
2. The continue statement breaks the loops one by one. ……………………
3. To come out of the infinite loop, we can either close the program window
or press Ctrl + C. ……………………
4. A sequence is a succession of values bound together by a single name. ……………………
5. The while statement is the looping statement. ……………………
Looping Statements in Python 51

