Files
Learn-Python-Programming-Th…/ch03/ternary.py
T
adii1823 8b802c5c62 ch03
2021-10-28 17:34:45 +05:30

13 lines
246 B
Python

order_total = 247 # GBP
# classic if/else form
if order_total > 100:
discount = 25 # GBP
else:
discount = 0 # GBP
print(order_total, discount)
# ternary operator
discount = 25 if order_total > 100 else 0
print(order_total, discount)