Answer Posted / chaitanya
The ternary operator is the operator that is used to show the conditional statements. This consists of the true or false values with a statement that has to be evaluated for it. The operator will be given as:
[on_true] if [expression] else [on_false]
x, y = 25, 50
big = x if x < y else y
This is the lowest priority operator that is used in making a decision that is based on the values of true or false. The expression gets evaluated like if x<y else y, in this case if x<y is true then the value is returned as big=x and if it is incorrect then big=y will be sent as a result.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is pytest?
You mentioned pypi in your previous answer. Can you elaborate?
What is the difference between = and == in python?
Is python or r more useful?
What is a decorator in python?
What is python and explain some of its benefits?
What does while 1 mean in python?
What is casting in python?
What is the difference between old style and new style classes in python?
What is the incorrect declaration of a set?
What is lambda function ?
What does * args mean in python?
How to get the ascii value in python?
What is GIL? What does it do?Talk to me about the GIL. How does it impact concurrency in Python? What kinds of applications does it impact more than others?
Where can I learn python for free?