Python Multiple Choice Question – Looping [set-1]

Python Multiple choice questions based on Looping structure available in python. These looping structures explore the basics of loops and other python data types.

python mcq-set-1

Each MCQ question has four probable solutions and its answer with explanation. Read each question carefully before answering.

Q1. Find the output of the following Python Code

fruits = [“apple”,”banana”,”cherry”]
for  x in fruits:
print(x)
A) “apple”, “banana”, “cherry”
b) “a”, “b”,”c”
c) 0,1,2
d) None of the above

Show Answer

Option (A) Explaination :  x will take each item from the list and display it

Q2. Find out the output of the following python Program
fruits = [“apple”, “banana”, “cherry”]
for x in fruits:
if x == “banana”:
break
print(x)
a) “apple”, “banana”, “cherry”
b) “apple”
c) “banana”
d) None of the above

Show Answer

Option (b) Explanation : Since loop will terminate at “banana” it will only show only “apple”

Q3.  Find the output of the following Python Program 
for x in range(1,20,3):
print(x)
a) 1,4,7,10,13,16,19
b) 1,20,3
c) 13,6,9,12,15,18
d) None of above

Show Answer

Option (a) Explaination :  Range() function take first number as its starting point and then increment the number by 3 and will move the numbe upto 19.

Q4. Find out the output of the following program
birds = [‘Belle’, ‘Snow’, ‘Juniper’, ‘Lilly’, ‘Swara’]
ignoreElse = False
for theBird in birds:
print(theBird )
if ignoreElse and theBird is ‘Snow’:
break
else:
print(“No birds left.”)
a) ‘Belle’
b) “Belle’, ‘Snow’, ‘No birds left’
c) ‘Belle’ , ‘No birds left’
d) ‘ ‘Belle’,’Snow’

Show Answer

Option (d) Explanation:  Since ‘break’ will terminate the loop thus ‘else’ statement will not take place

Q5. Find out the output of the following Python Program 

if (7 < 0) and (0 < -7):
print(“abhi”)
elif (7 > 0) or False:
print(“love”)
else:
print(“cbsetoday.com”)
a)abhi
b) love
c) cbsetoday.com
d) none of the above

Show Answer

Option (b) Explaination : This will print according to the true condition only

Q6.  Find out the output of the following program segment

for i in range(10):
print(i)
a) 0,1,2,3,4,5,6,7,8,9
b) 1,2,3,4,5,6,7,8,9,10
c) 10
d) None of the abobe

Show Answer

Option (a) Explaination :  range(10) will generate values from 1 to 9 thus option (a)

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.