Page 229 - Computer Science Class 11 Without Functions
P. 229
Solved Exercise
A. Multiple Choice Questions
1. A ____________ construct is used for repeated execution of statements.
a. Looping b. Selection c. Sequential d. None of the above
2. Which of the following statements will terminate a loop?
a. pass b. continue c. break d. All of the above
3. The expression range(10, 2, -4) will yield the sequence:
a. 10, 6, 2 b. 9, 5, 2 c. 10, 6 d. 9, 5
4. How many values will be printed on execution of the following loop?
for z in range(3):
print(z)
a. 4 b. 2 c. 3 d. None of the above
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 the above
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. ________
Looping in Python 227

