Question Detail

BIO 107 While Loops & Control Flow Objective Question

Question

In the 'Guess the Number Game' Python code, why is while True: used?
Options
A To ensure the loop runs only once.
B To create a loop that will explicitly run until the program crashes.
C To keep asking for a guess indefinitely until an explicit <code>break</code> statement is met.
Correct Answer
D It's a placeholder and has no functional meaning.
Correct Answer

Option C is the correct answer.

Detailed Explanation

Slide 12 (and the code on Slide 13) specifies: 'Use while True: to keep asking for a guess.' This creates an infinite loop that must be exited by a break statement when the correct guess is made.

Hint

Consider what happens if the loop condition is always true, and how it relates to the `break` statement in the game.

Question Info