Page 165 - Information_Practice_Fliipbook_Class11
P. 165
5. What will be the value of num after the following loop is executed?
for num in range(5):
pass
a. 6 b. 4 c. 5 d. None of these
6. What will be the value of var after the following loop is executed?
var=5
while(var<=10):
var=var+1
a. 12 b. 11 c. 10 d. 5
7. Which of the following is the correct example of nested loop?
a. for x in range(1,5):
for y in range(x):
print(x)
b. for x in range(1,5):
for y in range(x):
print(x)
c. for x in range(1,5):
print(x)
for y in range(x):
print(y)
d. for x in range(1,5):
for y in range(x):
print(x)
8. A loop becomes an infinite loop if the test condition never becomes ____________.
a. True b. False c. Null d. None
B. State whether the following statements are True or False:
1. The body of the loop can have only one statement. ________
2. The range() generates a sequence of numbers within a given range. ________
3. The default start value of range() is 1. ________
4. If a break statement is encountered inside a nested loop, the outermost loop is terminated. ________
5. Nothing happens when a pass statement is executed. ________
6. The control variable should always be initialized before the while loop begins. ________
C. Fill in the blanks.
1. The ____________ block of the loop is executed when all the iterations of the loop have been executed.
2. In a for loop, the ____________ variable keeps track of the number of times the body of the loop has been executed.
3. The ____________ statement terminates the execution of the loop.
4. In the case of a nested loop, the ____________ loop will iterate over the next element in the sequence only after all
iterations of the ____________ loop have been executed.
5. If in a program, the test condition of a loop does not evaluate to False at all, then such a loop is called ____________
loop.
6. The ____________ statement is an empty statement in Python.
D. Answer the following questions:
1. Define iteration.
Ans. The repetition of statements is called iteration.
2. Identify the test expression from the following code:
num=2
Looping in Python 151

