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
Are tuples hashable?
What is docstring in Python?
Does python support multiple inheritance?
What are the key points of python?
How does python handle memory management?
Do we need to call the explicit methods to destroy the memory allocated in python?
What is the keyword to import a module in python?
What are the advantages of python?
Explain inheritance in python with example?
Which method removes leading and trailing blanks in a string?
How do I sort a dictionary by value?
Please explain what are the rules for local and global variables in python?
How do you define a function in python 3?
How do I quit python?
Is there a constructor in python?