Comprehensive and Detailed Explanation From Exact Extract:
A while loop repeatedly executes a block of code as long as a condition is true, making it suitable for tasks requiring iteration until a condition changes. According to foundational programming principles, while loops are ideal for scenarios with an unknown number of iterations or conditional repetition.
Option A: "When the user inputs a number, the program outputs 'True' when the number is a multiple of 10." This is incorrect. This task requires a single check (number % 10 == 0), which can be done with an if statement, not a loop.
Option B: "The user inputs an integer, and the program prints out whether the number is even or odd and whether the number is positive, negative, or zero." This is incorrect. This task involves a single input and multiple conditional checks, handled by if statements, not a loop.
Option C: "After inputting two numbers, the program prints out the larger of the two." This is incorrect. Comparing two numbers requires a single if statement (e.g., if (a > b)), not a loop.
Option D: "A user is asked to enter a password repeatedly until either a correct password is entered or five attempts have been made." This is correct. This task requires repeated input until a condition is met (correct password or five attempts), which is ideal for a while loop. For example, in Python:
attempts = 0
while attempts < 5 and input("Password: ") != "correct":
attempts += 1
Certiport Scripting and Programming Foundations Study Guide (Section on Control Structures: Loops).
Python Documentation: “While Statements” (https://docs.python.org/3/reference/compound_stmts.html#while).
W3Schools: “C While Loop” (https://www.w3schools.com/c/c_while_loop.php).