Interview Questions

Most Essential And Frequently Asked Interview
Questions And Answer


Q.Ternary Operator in Python


Python | Ternary Operator

python uses an if-else conditional statement in a single line to represent the Ternary Operator.

[true] if [expression] else [false]

Let's see an example of Ternary Operator

a, b = 10, 20
max = a if a > b else b 

The above program is showing an example of finding the max number among two numbers using the Ternary operator.