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 |
How will you convert an integer to a unicode character in python?
Why python is faster than java?
Is python 3gl or 4gl?
What's a negative index?
What does __ init __ py do in python?
What is numpy? Is it better than a list?
Does python has private keyword in python ? How to make any variable private in python ?
How type casting is done in python?
What is multithreading? Give an example?
Can I create a website with Python?
What does range () do in python?
Can I use python to make a website?