Home »
MCQs »
Python MCQs
What will be the output of the following Python code? Question 4
36. What will be the output of the following Python code?
num = 10
if num > 0:
print("Positive number")
elif num == 0:
print("Zero")
else:
print("Negative number")
- Positive number
- Negative number
- Real number
- None of the mentioned above
Answer: A) Positive number
Explanation:
In this case, the If condition is evaluated first and then the else condition. If it is true, the elif statement will be executed. If it is false, nothing will happen. elif is an abbreviation for else if. It enables us to check for multiple expressions at the same time. Similarly, if the condition for if is False, the condition for the next elif block is checked, and so on. If all of the conditions are met, the body of the else statement is run.