if嵌套是流程控制中的基础之一
if 条件1:
条件1满足执行的动作
if 满足条件1的基础的条件2:
…
else:
条件2不满足的情况下
else:条件1不满足时执行的动作
用if嵌入计算机票价格:
price = 5000
month = int(input("请输入月份:"))
location = str(input(“请输入仓位:”))
if 0 < month < 4 or 11 <= month<= 12:
if location == "头等舱":
print("价格为",price*0.5)
if location == "经济舱":
print("价格为",price*0.4)
else :
if location =="头等舱":
print("价格为",price*0.9)
if location =="经济舱":
print("价格为",price*0.8)