You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
python-gjk/08/tenary_operator.md

500 B

Tenarni operator

Unarni operatory jsou operatory ktery berou 1 vstup. Napriklad not je unarni operator.

Binarni operatory jsou operatory ktery berou 2 vstupy. Napriklad + je binarni operator.

Tenarni operator je operator ktery bere 3 vstupy. Ten je v pythonu tedy jenom jeden vypada takto:

n = 2 # nejaky cislo
print("sudy" if n % 2 == 0 else "lichy") # vypise `sudy` protoze n je sudy

coz je ekvivalence:

n = 2
if n % 2 == 0:
	print("sudy")
else:
	print("lichy")