Question Detail

BIO 107 While Loops & Control Flow Objective Question

Question

In the 'Guess the Number Game Python Code' on page 13, why is while True: used for the main game loop?
Options
A It ensures the loop runs exactly once.
B It makes the loop wait for a specific time interval.
C It signifies that the loop will run indefinitely until an explicit <code>break</code> statement is encountered.
Correct Answer
D It checks if the <code>secret_number</code> is a boolean <code>True</code>.
Correct Answer

Option C is the correct answer.

Detailed Explanation

Using while True: creates an unconditional loop that runs forever. The loop is designed to exit only when the correct guess is made, triggering the break statement within the if block.

Hint

True is a constant boolean value. What does a while loop do when its condition is always true?

Question Info