-
Hajipur, Bihar, 844101
Hajipur, Bihar, 844101
Difficulty Level: medium
Q1: What will be the output of the following code? (1 points)
x = 10
if x > 5:
print("High")
else:
print("Low")
Q2: Which keyword is used to check multiple conditions in Python? (1 points)
Q3: What is the output of this code? (1 points)
x = 0
while x < 3:
print(x)
x += 1
Q4: What will this code print? (1 points)
for i in range(1, 6):
if i == 3:
break
print(i)
Q5: What does the continue statement do in Python? (1 points)
Q6: What will be the output of the following code? (1 points)
for i in range(5):
if i == 2:
continue
print(i)
Q7: Which of the following statements will execute only when all loop iterations are completed without using break? (1 points)
Q8: What is the output? (1 points)
x = 5
if x < 0:
print("Negative")
elif x == 0:
print("Zero")
else:
print("Positive")
Q9: How many times will this loop run? (1 points)
count = 0
while count < 4:
count += 1
print(count)
Q10: Which of the following can be used to iterate over both a range and a list? (1 points)
Q11: What is the output of this code? (1 points)
for i in range(3):
print("Hello")
else:
print("Done")
Q12: What does the following code print? (1 points)
num = 7
if num % 2 == 0:
print("Even")
else:
print("Odd")
Q13: What happens if the condition in a while loop is always True? (1 points)
Q14: Which of these statements correctly describes a match statement in Python? (1 points)
Q15: What will be printed? (1 points)
for i in range(1, 5):
if i == 4:
break
print(i)
else:
print("Loop Finished")
Q16: What is the output of the following code? (1 points)
x = 10
if x > 20:
print("Greater")
elif x == 10:
print("Equal")
else:
print("Smaller")
Q17: Which statement immediately exits a loop, skipping all remaining iterations? (1 points)
Q18: What is the output of this code? (1 points)
for i in range(1, 4):
for j in range(1, 3):
print(i, j)
Q19: What will be printed? (1 points)
for i in range(3):
pass
print("Done")
Q20: What is the output of the following code? (1 points)
x = 5
while x > 0:
print(x)
x -= 2
Q21: Identify the correct syntax of a Python match statement. (1 points)
Q22: What is the output? (1 points)
for num in range(2, 10, 3):
print(num)
Q23: What will happen if the condition in an if-else chain never becomes true? (1 points)
Q24: Which keyword is used to define an empty loop body in Python? (1 points)
Q25: What will be the final value of x after executing this code? (1 points)
x = 0
while x < 5:
x += 1
if x == 3:
break
Q26: What will be the output of the following code? (1 points)
for i in range(1, 4):
for j in range(1, 3):
if j == 2:
continue
print(i, j)
Q27: What happens when the break statement is used inside nested loops? (1 points)
Q28: What is the purpose of using an else block with a while loop? (1 points)
Q29: Predict the output: (1 points)
for i in range(5):
if i % 2 == 0:
print(i)
Q30: What does the pass statement do in an if condition? (1 points)
Q31: What is the output? (1 points)
x = 1
while x < 4:
print(x)
x += 1
else:
print("Done")
Q32: What does the following code output? (1 points)
for i in range(3):
for j in range(2):
if i == j:
break
print(i, j)
Q33: What does the following code do? (1 points)
match 2:
case 1:
print("One")
case 2:
print("Two")
case _:
print("Default")
Q34: What will this loop print? (1 points)
for ch in "PYTHON":
if ch == "H":
break
print(ch)
Q35: What happens if you write an else after a break statement directly? (1 points)
Q36: What will the following code output? (1 points)
for i in range(1, 6):
if i % 2 == 0:
continue
print(i, end=" ")
Q37: What will be the output of this code? (1 points)
for i in range(1, 5):
if i == 3:
continue
print(i)
Q38: What happens when the following code runs? (1 points)
for i in range(5):
if i == 2:
break
print(i)
Q39: What will be printed? (1 points)
x = 0
while x < 3:
print(x)
x += 1
else:
print("Done")
Q40: What will be the output of this code? (1 points)
for i in range(3):
pass
print("Finished")
Q41: What does the else block in a for loop do in Python? (1 points)
Q42: What will this code output? (1 points)
for i in range(5):
if i == 3:
break
else:
print("Loop ended")
Q43: Which of these loops can be infinite if no condition changes? (1 points)
Q44: What does this code do? (1 points)
i = 0
while True:
if i == 4:
break
print(i)
i += 1
Q45: What will happen here? (1 points)
for i in range(3):
for j in range(2):
print(i, j)
Q46: What does this print? (1 points)
for i in range(2):
for j in range(2):
if j == 1:
continue
print(i, j)
Q47: What will happen if we place a break inside nested loops? (1 points)
Q48: Which keyword is used to skip a loop iteration? (1 points)
Q49: Which of these is an infinite loop? (1 points)
Q50: What does the following code print? (1 points)
for i in range(3):
if i == 1:
pass
print(i)
Welcome to the Python Control Structure Quiz.
This quiz is designed to test your understanding of Python’s decision-making and looping structures, including conditional statements, match, for loops, while loops and loop control. Please read the instructions before starting.
Quiz Format
Total Questions: 50
Difficulty Level: Medium
Question Type: Multiple Choice
Each question has one correct answer.
Timing
You will get a total of 25 minutes to finish the quiz.
Manage your time carefully and move through each question at a steady pace.
Scoring
Each correct answer = +1 point
No negative marking
Maximum Score = 50 points
How to Play
Read each question carefully.
Understand how the control structure in the code behaves.
Select the option you think is correct.
Once you move to the next question, you cannot go back.
Rules
Do not refresh or close the quiz page.
Avoid external help or searching online.
Keep track of the timer while attempting the quiz.
Before You Start
You can learn the related tutorials here:
Conditional Statements: π Learn Here π
Match Statement: π Learn Here π
For Loop: π Learn Here π
While Loop: π Learn Here π
Loop Control: π Learn Here π
After Submission
Your score will be displayed immediately.
You can review the correct answers to learn and improve.
