Python Programming - Tricky Questions - Discussion
Discussion Forum : Tricky Questions - General Questions (Q.No. 36)
36.
What is the output of the following Python code?
x = 5
y = x if x > 10 else x/2
print(y)
Answer: Option
Explanation:
The ternary conditional expression sets
y
to x
if x > 10
, otherwise it sets y
to x/2
.
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