1>>> i=100
2>>> a = 1 if i<100 else 2 if i>100 else 0
3>>> a
40
5>>> i=101
6>>> a = 1 if i<100 else 2 if i>100 else 0
7>>> a
82
9>>> i=99
10>>> a = 1 if i<100 else 2 if i>100 else 0
11>>> a
121
1is_fast = True
2car = "Ferrari" if is_fast else "Sedan"
3# with tuples (avoid):
4car = ("Sedan", "Ferrari")[is_fast]
5# ShortHand ternary
6msg = True or "Some" # True
7msg = False or "Some" # 'Some'
8output = None # -> False
9msg = output or "No data returned" # 'No data returned'