Interview Questions




Most Essential And Frequently Asked Interview
Questions And Answer

Python

Q.Ternary Operator in Python

Ans.:

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 
  
print(max)

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