Question Detail

BIO 107 While Loops & Control Flow Objective Question

Question

In the 'Guess the Number Game Python Code,' what is the purpose of int(input('Guess the secret number: '))?
Options
A To display a message and store the user's input as a string.
B To convert the user's string input into an integer.
Correct Answer
C To generate a random secret number.
D To check if the user's input is a valid number.
Correct Answer

Option B is the correct answer.

Detailed Explanation

The input() function always returns user input as a string. The int() function then converts this string into an integer, which is essential for numerical comparisons with the secret_number.

Hint

User input is always a string by default. What operation is needed if you want to perform arithmetic or direct numerical comparison?

Question Info