How can the ternary operators be used in python?
Answer / 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 |
Has python has monkey patching concept within?
Can we use else block with for loop? Answer with one example.
Can we use angularjs with python?
How are inheritance and overriding methods are related?
Is there a switch or case statement in python? If not then what is the reason for the same?
Do sheeps sleep?
What is sys stdout flush ()?
What is a raw input in python?
What is super () react?
How many types of loops are there in python?
Explain how memcached should not be used in your python project?
How can I force division to be floating point in python?