Python Control Structure MCQ
MCQ
Python Control Statements
40 Multiple Choice Questions (MCQs)
1. Which statement is used for decision-making in Python?
(a) for
(b) while
(c) if
(d) break
Answer: (c) if
2. Which keyword is used with if when the condition is false?
(a) then
(b) else
(c) case
(d) switch
Answer: (b) else
3. Which statement is used to check multiple conditions?
(a) nested if
(b) if-else
(c) if-elif-else
(d) while
Answer: (c) if-elif-else
4. What is the output?
x = 10
if x > 5:
print("Yes")
(a) No
(b) Yes
(c) Error
(d) Nothing
Answer: (b) Yes
5. Which keyword is used to test another condition after if?
(a) else
(b) elif
(c) then
(d) while
Answer: (b) elif
6. What is the output?
x = 5
if x > 10:
print("A")
else:
print("B")
(a) A
(b) B
(c) Error
(d) Nothing
Answer: (b) B
7. Which of the following is a looping statement?
(a) if
(b) elif
(c) for
(d) else
Answer: (c) for
8. Which loop is used to repeat a block of code a fixed number of times?
(a) while
(b) for
(c) if
(d) else
Answer: (b) for
9. Which loop is condition-based?
(a) for
(b) while
(c) nested for
(d) range
Answer: (b) while
10. What is the output?
for i in range(3):
print(i)
(a) 1 2 3
(b) 0 1 2
(c) 0 1 2 3
(d) 1 2
Answer: (b) 0 1 2
11. What is the output?
for i in range(1,4):
print(i)
(a) 1 2 3
(b) 0 1 2 3
(c) 1 2 3 4
(d) 0 1 2
Answer: (a) 1 2 3
12. Which function is commonly used with a for loop?
(a) input()
(b) print()
(c) range()
(d) len()
Answer: (c) range()
13. What is the output?
for i in range(2,8,2):
print(i)
(a) 2 4 6
(b) 2 4 6 8
(c) 1 3 5 7
(d) 0 2 4 6
Answer: (a) 2 4 6
14. Which statement terminates a loop immediately?
(a) continue
(b) pass
(c) break
(d) stop
Answer: (c) break
15. Which statement skips the current iteration?
(a) continue
(b) break
(c) pass
(d) exit
Answer: (a) continue
16. What is the output?
for i in range(5):
if i == 3:
break
print(i)
(a) 0 1 2
(b) 0 1 2 3
(c) 1 2 3
(d) 0 1
Answer: (a) 0 1 2
17. What is the output?
for i in range(5):
if i == 2:
continue
print(i)
(a) 0 1 2 3 4
(b) 0 1 3 4
(c) 2 3 4
(d) 0 1 2
Answer: (b) 0 1 3 4
18. Which statement does nothing and acts as a placeholder?
(a) continue
(b) break
(c) pass
(d) skip
Answer: (c) pass
19. What is the output?
x = 20
if x > 10:
print("Large")
(a) Small
(b) Large
(c) Error
(d) None
Answer: (b) Large
20. Nested if means:
(a) if inside another if
(b) loop inside loop
(c) if inside for
(d) while inside while
Answer: (a) if inside another if
21. What is the output?
x = 8
if x > 5:
if x < 10:
print("Valid")
(a) Valid
(b) Invalid
(c) Error
(d) Nothing
Answer: (a) Valid
22. Which symbol indicates a block after an if statement?
(a) ;
(b) :
(c) ,
(d) .
Answer: (b) :
23. Python uses _________ to define blocks.
(a) Braces
(b) Semicolons
(c) Indentation
(d) Parentheses
Answer: (c) Indentation
24. Which of the following is correct?
(a)
if x>5
(b)
if(x>5):
(c)
if x>5:
(d) Both (b) and (c)
Answer: (d) Both (b) and (c)
25. What is the output?
x = 4
if x % 2 == 0:
print("Even")
(a) Odd
(b) Even
(c) Error
(d) Nothing
Answer: (b) Even
26. Which loop can execute zero times?
(a) for
(b) while
(c) both
(d) none
Answer: (c) both
27. Which loop is preferred when the number of iterations is known?
(a) while
(b) for
(c) nested while
(d) infinite loop
Answer: (b) for
28. What is an infinite loop?
(a) Loop runs once
(b) Loop never executes
(c) Loop never ends
(d) Loop with errors
Answer: (c) Loop never ends
29. Which of the following creates an infinite loop?
while True:
print("Hello")
(a) Infinite Loop
(b) Error
(c) Executes once
(d) None
Answer: (a) Infinite Loop
30. What is the output?
i = 1
while i <= 3:
print(i)
i += 1
(a) 1 2 3
(b) 0 1 2
(c) 1 2
(d) Error
Answer: (a) 1 2 3
31. What is the output?
for i in range(1):
print("Python")
(a) Python
(b) Python Python
(c) Error
(d) Nothing
Answer: (a) Python
32. Which statement exits from the nearest loop?
(a) continue
(b) break
(c) pass
(d) return
Answer: (b) break
33. Which control statement is used for selection?
(a) if
(b) for
(c) while
(d) break
Answer: (a) if
34. Which control statement is used for repetition?
(a) if
(b) loop
(c) pass
(d) break
Answer: (b) loop
35. What is the output?
x = 7
if x > 5:
print("A")
else:
print("B")
(a) A
(b) B
(c) AB
(d) Error
Answer: (a) A
36. Which of the following is not a control statement?
(a) if
(b) for
(c) while
(d) print
Answer: (d) print
37. What is the output?
for i in range(3):
pass
print("Done")
(a) Done
(b) Error
(c) 0 1 2 Done
(d) Nothing
Answer: (a) Done
38. Which keyword is optional in an if statement?
(a) if
(b) elif
(c) else
(d) Both (b) and (c)
Answer: (d) Both (b) and (c)
39. What is the output?
x = 3
if x > 5:
print("A")
elif x > 2:
print("B")
(a) A
(b) B
(c) Error
(d) Nothing
Answer: (b) B
40. Control statements are used to:
(a) Control the flow of execution
(b) Create variables
(c) Store data
(d) Define functions
Answer: (a) Control the flow of execution


