Question Detail

BIO 107 While Loops & Control Flow Objective Question

Question

Consider the counting example: count = 1; while count <= 5: print("Number:", count); count = count + 1. What will be the value of count immediately after the print statement executes for the first time?
Options
A 1
Correct Answer
B 2
C 5
D 6
Correct Answer

Option A is the correct answer.

Detailed Explanation

Initially, count is 1. The condition 1 <= 5 is true. The print statement then executes, displaying 'Number: 1'. At this point, count is still 1. It only becomes 2 after the count = count + 1 line.

Hint

Trace the execution line by line. The increment happens after the print statement in each iteration.

Question Info