Question Detail
Question
What would be the output of the following Python code?
temp = 32
if temp > 30:
print("Hot Day")
elif temp > 15:
print("Nice Day")
else:
print("Cold Day")
Correct Answer
Option A is the correct answer.
Detailed Explanation
This code is directly from Page 13. The first condition
temp > 30 (32 > 30) is True. Therefore, 'Hot Day' is printed, and the rest of the elif and else blocks are skipped.
Hint
Python evaluates conditions in order and executes the first True block it finds.