Question Detail

COS 102 If staments Objective Question

Question

Consider the following Python code snippet:
x = 15
if x > 10:
print(x)
What will be the output when this code is executed?
Options
A 10
B 15
Correct Answer
C No output
D An error
Correct Answer

Option B is the correct answer.

Detailed Explanation

As seen in 'Classroom Activity' on page 16 (case 1), x is 15. The condition x > 10 (15 > 10) is True, so print(x) will execute, printing 15.

Hint

Evaluate the condition with the given value of 'x'.

Question Info