SIMATS ENGINEERING
SAVEETHA INSTITUTE OF MEDICAL AND TECHNICAL SCIENCES
CHENNAI-602105
CSA0810-PYTHON PROGRAMMING
Reg. No :
Name :
Assignment – II
Python MCQs – Conditional Statements & Loops
Conditional Statements (if, elif, else)
1. Which keyword is used for conditional branching in Python?
a) if
b) switch
c) case
d) select
2. What is the output of:
x = 10
if x > 5:
print("Yes")
else:
print("No")
a) Yes
b) No
c) Error
d) Nothing
3. Which of the following is the correct syntax for an if statement?
a) if x > 10 then:
b) if (x > 10)
c) if x > 10:
d) if x > 10;
4. What is the output of:
x=5
if x < 5:
print("A")
elif x == 5:
print("B")
else:
print("C")
a) A
b) B
c) C
d) Error
5. Which operator is used for multiple conditions in if statements?
a) and / or
b) plus / minus
c) in / not in
d) with / as
SIMATS ENGINEERING
SAVEETHA INSTITUTE OF MEDICAL AND TECHNICAL SCIENCES
CHENNAI-602105
CSA0810-PYTHON PROGRAMMING
6. What is the output of:
if 0:
print("True")
else:
print("False")
a) True
b) False
c) 0
d) Error
7. Which value is considered False in condition checks?
a) 0
b) None
c) "" (empty string)
d) All of the above
8. Can we write if without else in Python?
a) Yes
b) No
c) Only inside loops
d) Only in functions
9. What is the output of:
x = 10
if x:
print("True")
a) True
b) False
c) Nothing
d) Error
10. Which keyword is used for testing multiple conditions in Python?
a) switch
b) else if
c) elif
d) elseif
Loops (for, while)
11. Which loop is used to iterate over a sequence in Python?
a) for
b) while
c) do-while
d) repeat-until
12. Which loop continues until a condition becomes false?
a) for
b) while
c) do-while
d) switch
SIMATS ENGINEERING
SAVEETHA INSTITUTE OF MEDICAL AND TECHNICAL SCIENCES
CHENNAI-602105
CSA0810-PYTHON PROGRAMMING
13. What is the output of:
for i in range(3):
print(i)
a) 0 1 2 3
b) 1 2 3
c) 0 1 2
d) Error
14. What is the output of:
i=1
while i < 3:
print(i)
i += 1
a) 1 2 3
b) 1 2
c) 0 1 2
d) Infinite loop
15. Which function generates a sequence of numbers?
a) range()
b) seq()
c) series()
d) list()
16. What is the output of range(2, 5)?
a) 2 3 4 5
b) 2 3 4
c) 2 3
d) 2 3 4 5 6
17. What is the output of range(2, 10, 2)?
a) 2 3 4 5 6 7 8 9
b) 2 4 6 8
c) 2 5 8
d) 2 10
18. Which keyword is used to exit a loop prematurely?
a) continue
b) break
c) exit
d) stop
19. Which keyword skips the current iteration of a loop?
a) continue
b) break
c) pass
d) next
20. Which statement is used as a placeholder with no action?
a) skip
b) continue
c) pass
d) null
SIMATS ENGINEERING
SAVEETHA INSTITUTE OF MEDICAL AND TECHNICAL SCIENCES
CHENNAI-602105
CSA0810-PYTHON PROGRAMMING
Nested Loops & else in loops
21. Can loops be nested inside each other in Python?
a) Yes
b) No
c) Only for loops
d) Only while loops
22. What is the output of:
for i in range(2):
for j in range(2):
print(i, j)
a) (0,0) (0,1) (1,0) (1,1)
b) (0,1) (1,0) (1,1)
c) (0,0) (1,1)
d) Error
23. Which block executes if the loop completes normally without break?
a) try
b) else
c) finally
d) except
24. What is the output of:
for i in range(3):
print(i)
else:
print("Done")
a) 0 1 2
b) 0 1 2 Done
c) Done
d) Error
25. What is the output of:
for i in range(3):
if i == 1:
break
else:
print("Done")
a) 0 1 2 Done
b) 0 1 2
c) 0
d) 0 1
26. What is the output of:
i=0
while i < 3:
print(i)
i += 1
else:
print("Finished")
a) 0 1 2 Finished
b) 0 1 2
c) Finished
d) Infinite loop
SIMATS ENGINEERING
SAVEETHA INSTITUTE OF MEDICAL AND TECHNICAL SCIENCES
CHENNAI-602105
CSA0810-PYTHON PROGRAMMING
27. Which statement is correct about loop else?
a) Runs if loop ends normally
b) Runs only in while loop
c) Runs only in for loop
d) Never runs
28. What is the output of:
for i in range(2):
for j in range(2):
if j == 1:
break
else:
print("Inner else")
a) Inner else
b) Inner else Inner else
c) Nothing
d) Error
29. Which loop is best when the number of iterations is known?
a) for
b) while
c) do-while
d) None
30. Which loop is best when the number of iterations is unknown?
a) for
b) while
c) do-while
d) None
Advanced & Edge Cases
31. What is the output of:
for i in []:
print("Loop")
else:
print("Else")
a) Loop
b) Else
c) Nothing
d) Error
32. What is the output of:
count = 0
while count < 0:
print("Hello")
else:
print("Bye")
a) Hello Bye
b) Bye
c) Nothing
d) Error
SIMATS ENGINEERING
SAVEETHA INSTITUTE OF MEDICAL AND TECHNICAL SCIENCES
CHENNAI-602105
CSA0810-PYTHON PROGRAMMING
33. What is the output of:
for i in range(1, 10, 3):
print(i)
a) 1 4 7
b) 1 2 3 4 5 6 7 8 9
c) 1 3 6 9
d) 3 6 9
34. Which loop will always run at least once in other languages but not in Python?
a) for
b) while
c) do-while
d) None
35. Which keyword is used to stop execution inside nested loops?
a) stop
b) continue
c) break
d) exit
36. What is the output of:
for i in range(2):
pass
print("Done")
a) Done
b) 0 1 Done
c) Nothing
d) Error
37. Which function is commonly used to loop a fixed number of times?
a) loop()
b) range()
c) count()
d) repeat()
38. What is the output of:
for i in "abc":
print(i)
a) a
b) a b c
c) abc
d) Error
39. What is the output of:
for i in range(5, 5):
print(i)
a) 5
b) 0
c) Nothing
d) Error
40. Which loop is faster for iterating over a list?
a) for
b) while
c) Both same
d) Depends on condition
SIMATS ENGINEERING
SAVEETHA INSTITUTE OF MEDICAL AND TECHNICAL SCIENCES
CHENNAI-602105
CSA0810-PYTHON PROGRAMMING
Comprehensions & Misc
41. What is the output of:
[x for x in range(3)]
a) [0, 1, 2]
b) 0 1 2
c) (0,1,2)
d) Error
42. What is the output of:
[x**2 for x in range(3)]
a) [1, 2, 3]
b) [0, 1, 4]
c) [2, 4, 6]
d) Error
43. Which statement can replace nested if-else in short form?
a) match-case
b) ternary operator
c) switch
d) select
44. What is the correct ternary expression for x=5; result="Yes" if x>0 else "No"?
a) Yes if x>0 else No
b) result = "Yes" if x>0 else "No"
c) if x>0 ? Yes : No
d) None
45. Which loop supports else clause?
a) for
b) while
c) both for and while
d) None
46. What is the output of:
for i in range(3):
if i == 2:
continue
print(i)
a) 0 1
b) 0 1 2
c) 1 2
d) 2
47. What is the output of:
for i in range(3):
if i == 1:
pass
print(i)
a) 0 2
b) 0 1 2
c) 0 1
d) 1 2
SIMATS ENGINEERING
SAVEETHA INSTITUTE OF MEDICAL AND TECHNICAL SCIENCES
CHENNAI-602105
CSA0810-PYTHON PROGRAMMING
48. Which loop is infinite if condition is always true?
a) for
b) while
c) both
d) none
49. Which function converts range object to list?
a) list()
b) tolist()
c) convert()
d) array()
50. Which statement about loops is false?
a) for can iterate over lists
b) while is condition-based
c) for can iterate over strings
d) Python supports do-while