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 are membership operators in python? Write an example to explain both.
How can you convert a number to string?
Explain the database connection in python flask?
What is the use of metaclass in python?
What is python api?
Name the built-in types provided by python?
What is a control flow statement?
What is the output of the below program?
How memcached should not be used in your python project?
How to find the index of an item given a list containing it in python?
What are the difference between python and java?
which standard datatype in python is immutable?
Is python an oops?
How to concatenate two lists in python?
What is set () in python?