Page 166 - Information_Practice_Fliipbook_Class11
P. 166
while num<=10:
print(num)
num=num+1
Ans. num<=10
3. Name the essential components of any loop.
Ans. Sequence which may be a list, string, tuple or dictionary.
A control variable is a variable that takes the values in the sequence one by one.
Body of the loop.
4. Consider the following code snippet and determine the number of times print('In Loop')is executed:
counter = 10
while (counter < 20):
print('In Loop')
counter = counter - 10
else:
print(counter)
Ans. Infinite Loop. In Loop is printed 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
(iii) sweet='ice cream'
for ch in sweet:
if ch not in 'abcdefghijklmnopqrstuvwxyz':
pass
print(ch, end='')
Ans. ice cream
(iv) for i in (5,8):
for j in (3,6):
print(i*j, end=' ')
Ans. 15 30 24 48
(v) for i in (5,8):
for j in (3,6):
print(i*j, end=' ')
print()
Ans. 15 30
24 48
152 Touchpad Informatics Practices-XI

