Categories

Dec 22, 2019 in Python

Q: How Does The Ternary Operator Work In Python?

1 Answer

Dec 22, 2019

The ternary operator is an alternative for the conditional statements. It combines true or false values with a statement that you need to test.

The syntax would look like the one given below.

[onTrue] if [Condition] else [onFalse]

x, y = 35, 75

smaller = x if x < y else y

print(smaller)

Click here to read more about Python
Click here to read more about Insurance

Related questions

Madanswer
Aug 30 in Python
Aug 30 in Python
Aug 29 in Python
...