Page 174 - Information_Practice_Fliipbook_Class11
P. 174
4. What will be the output produced on the execution of the following code?
city = 'Chennai'
for c in city:
print(c.upper(), end='#')
a. CHENNAI# b. C#h#e#n#n#a#i# c. C#H#E#N#N#A#I# d. Chenai#
5. Which of the following statements is equivalent to range(5)?
a. range(0, 5) b. range(1, 5) c. range(0, 5, 0) d. range(1, 5, 1)
6. How many numbers will the following loop print ?
for i in range(-3):
print(i)
a. 2 b. 3 c. 0 d. Will result in an error
7. What will be the value of num after the following code is executed?
for num in range(10, 5, -2):
break
a. -2 b. 5 c. 6 d. 10
8. Which of the following is not a valid construct?
a. while-else b. if-else c. def-else d. for-else
9. What will be the output produced on the execution of the following code?
value = 1
while value<=4:
value = 1
print(value)
a. 4 b. 5 c. 6 d. No output
B. State whether the following statements are True or False:
1. The body of a loop should consist of more than one statement. __________
2. Statements in the body of the loop are indented at the level of indentation next to the level
at which the header is indented. __________
3. Statements in else block are executed when the loop terminates due to break statement. __________
4. The continue statement skips the body of the loop and the control moves out of the loop. __________
5. The statements in a while block will be executed as long as the condition specified in the
header clause of the while statement is True. __________
6. While specifying a range, it is optional to specify the start value. __________
C. Fill in the blanks.
1. Repeated execution of a sequence of statements is called ____________.
2. The ____________ block of a for loop will be executed on successful execution of a for loop.
3. The ____________ statement terminates the loop unconditionally.
4. In a nested loop, the break statement appearing in an inner loop terminates only the ____________ loop.
5. An execution of the loop's body is called an ____________ of the loop.
D. Answer the following questions:
1. Differentiate between:
(i) for loop and while loop
(ii) break and continue statements
2. How is the else clause in an if statement different from the else clause in a for loop?
3. What is an infinite loop? Explain with an example.
160 Touchpad Informatics Practices-XI

