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

Show Answer

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

Show Answer

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

Show Answer

Option (a)  Explanation : Since -3 treated as true thus print this infinite time

Print Friendly, PDF & Email

Related Posts

If you like CBSEToaday and would like to contribute, you can also write an article using submit article or mail your article to contribute@cbsetoday.com See your article appearing on the cbsetoday.com main page and help other students/teachers.