-
Hajipur, Bihar, 844101
Hajipur, Bihar, 844101
Difficulty Level: medium
Q1: What is the main purpose of a while loop in Python? (1 points)
Q2: What will be the output of this code? (1 points)
x = 0
while x < 3:
print(x)
x += 1
Q3: What will happen if the while condition never becomes False? (1 points)
Q4: How can you terminate a while loop before the condition becomes False? (1 points)
Q5: What does the continue statement do in a while loop? (1 points)
Q6: What will be the output? (1 points)
x = 5
while x > 0:
print(x, end=" ")
x -= 1
Q7: What is the output of this code? (1 points)
x = 0
while x < 5:
x += 1
if x == 3:
break
print(x)
Q8: How many times will this code run? (1 points)
x = 2
while x < 10:
x += 2
Q9: Which keyword is used to define an empty loop body? (1 points)
Q10: What is the output of this code? (1 points)
x = 1
while x <= 3:
print("Loop")
x += 1
else:
print("Done")
Q11: What will this code print? (1 points)
count = 0
while count < 3:
print("Python", count)
count += 1
else:
print("Loop finished")
Q12: What is the output? (1 points)
x = 0
while x < 5:
print(x)
x += 2
Q13: What will happen with this code? (1 points)
while False:
print("This will run")
Q14: What is the output? (1 points)
i = 1
while i <= 5:
if i == 3:
i += 1
continue
print(i)
i += 1
Q15: What will this code output? (1 points)
x = 10
while x:
print(x)
x -= 2
Welcome to the Python While Loop Quiz.
This quiz is designed to check your understanding of while loops, loop conditions and iteration flow in Python. Please read the instructions before you begin.
Quiz Format
Total Questions: 15
Difficulty Level: Medium
Question Type: Multiple Choice
Each question has one correct answer.
Timing
You will get a total of 10 minutes to finish the quiz.
Manage your time and move through each question steadily.
Scoring
Each correct answer = +1 point
No negative marking
Maximum Score = 15 points
How to Play
Read each question carefully.
Understand the loop condition and how the while loop executes or stops.
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 using external help or searching online.
Keep track of the timer.
Before You Start
Learn the Python while loop tutorial here: Python While Loop Tutorial
After Submission
Your score will be shown immediately.
You can review the correct answers to improve your understanding.
