Python Programming - Conditional Statements - Discussion

Discussion Forum : Conditional Statements - General Questions (Q.No. 31)
31.
What will be the output of the following code?
num = 0
if num:
    print("Non-zero")
else:
    print("Zero")
Non-zero
Zero
Error
No output
Answer: Option
Explanation:
The condition if num checks if num is truthy. Since num is 0, which is falsy, the code inside the else block is executed, printing "Zero."
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.