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)
5
2.5
10
This code will result in an error.
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:

Your comments will be displayed after verification.