if 、 else 、 elif
if condition:
statement
範例
#a等於1時,print Hellow World
if a=1
print("Hello World")
if condition:
statement1
else:
statement2
範例
if a>b:
print("Hello World")
else:
print("goodbye")
if condition1:
statement1
elif condition2 :
statement2
elif condition3 :
statement3
else:
statements4
範例
fruit_price = int(input("price: "))
if fruit_price >= 150:
print('expensive')
elif fruit_price >= 80:
print('reasonable price')
else:
print('cheap')