Question Detail

BIO 107 While Loops & Control Flow Objective Question

Question

In the ATM Security Check example, the loop condition is while pin != "1234":. What is the primary purpose of this specific condition?
Options
A To check if the <code>pin</code> variable is empty.
B To ensure the loop runs only a fixed number of times.
C To keep prompting the user for input until the correct PIN is entered.
Correct Answer
D To allow access if any 4-digit number is provided.
Correct Answer

Option C is the correct answer.

Detailed Explanation

Page 6 describes this example as "Wait for the user to provide the correct PIN before granting access." The loop continues as long as the pin is NOT equal to "1234".

Hint

The != operator means "not equal to".

Question Info