Question Detail

COS 102 If staments Objective Question

Question

Consider the following Python code snippet:
if score >= 50:
print("Pass")

If the value of score is 45, what will be the output?
Options
A "Pass"
B Nothing will be printed
Correct Answer
C An error will occur
D True
Correct Answer

Option B is the correct answer.

Detailed Explanation

Page 6 illustrates this syntax. If score is 45, the condition score >= 50 (45 >= 50) is False. When the condition is False, the indented code block (print("Pass")) is skipped entirely, as shown on Page 7. Therefore, nothing is printed.

Hint

What happens when the condition in an 'if' statement evaluates to False?

Question Info