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")
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:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers