Page 265 - Computer Science Class 11 With Functions
P. 265
4. If a break statement is encountered inside a nested loop, the outermost loop is terminated. __________
5. Nothing happens when pass 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
while num<=10:
print(num)
num=num+1
Ans. num<=10
3. Name the essential components of any loop.
Ans. Initialization, Termination or Test Condition, Update Expression, Body of the loop.
4. Consider the following code snippet and determine the number of times print('In Loop')is executed:
ctr=10
while(ctr<20):
print('In Loop')
ctr=ctr-10
else:
print(ctr)
Ans. Infinite Times
5. What will be the output produced on execution of the following code snippet?
(i)
sweet='ice cream'
for ch in sweet:
if ch in sweet:
print(ch, end='')
Ans. ice cream
(ii)
sweet='ice cream'
for ch in sweet:
if ch in 'abcdefghijklmnopqrstuvwxyz':
print(ch, end='')
print()
Ans. icecream
Looping in Python 263

