Python Multiple Choice Question – Looping [set-1]
Q7. Find out the output of the following python program
for i in range(1,5):
print(i)
else:
print(i)
a) 0,1,2,3,4,5
b) 0,1,2,3,4
c) 1,2,3,4
d) None of the above
Option (a) Explaination : When condition is false it will print value of i
Q8. Find out the output of the following python Program
true= False
while(true):
print(‘I am confused”)
else:
print( “why confused”)
a) I am confused
b) Why confused
c) No output
b) Both a and b
Option (b) Explaination : Since value of variable true is ‘false’
Q9. Find out the output of the following Python Program
i = -3
while (i)
print(‘Hello my dear’)
a) Hello my dear infinite time
b) Hello single time
c) No output
d) None of the above
Option (a) Explanation : Since -3 treated as true thus print this infinite time