Question Detail

COS 102 If staments Objective Question

Question

Based on the 'Classroom Activity' on page 16, what is the output of this Python code?
age = 14
if age >= 18:
print('Adult')
Options
A Adult
B 14
C No output
Correct Answer
D An error
Correct Answer

Option C is the correct answer.

Detailed Explanation

In 'Classroom Activity' on page 16 (case 2), age is 14. The condition age >= 18 (14 >= 18) is False. Therefore, the indented print('Adult') statement will not be executed, resulting in no output.

Hint

What happens if the 'if' condition is False and there is no 'else' clause?

Question Info