Question Detail
Question
Consider the Python code snippet:
What will be the last number printed by this loop?
count = 1
while count <= 5:
print("Number:", count)
count = count + 1What will be the last number printed by this loop?
Correct Answer
Option B is the correct answer.
Detailed Explanation
The loop runs as long as
count <= 5. When count is 5, it prints "Number: 5" and then count becomes 6. At this point, count <= 5 is False, and the loop terminates.
Hint
Trace the value of
count just before the loop condition becomes false.