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 python idle used for?
How do I sleep in python?
How is print statement represented in python 3 (v/s python2)?
What is python's parameter passing mechanism?
Is coding useful in finance?
How to redirect the output of a python script from standout(ie., A monitor) on to a file?
How do you reverse the string in python?
What is a namespace in python?
How python maintains conditional blocks?
What is the concatenation?
What is a function in python programming?
Is there polymorphism in python?
Explain other string literals?
What is cgi in python?
Is python good for coding?