7-1汽车租赁
train = input('请输入您要租赁的汽车名称:')
print('Let me see if I can find you a ' + train)
7-2餐馆订位
msg = input ('请输入用餐人数:')
if int(msg) > 8:
print('没有空桌')
else :
print('有空桌')
7-3 10的整数倍
msg = input('请输入一个数字,将自动计算是否为10的整数倍:')
if int(msg) % 10 == 0 :
print(msg + '是 10 的整数倍')
else:
print(msg + '不是 10 的整数倍')
7-4 比萨配料
msg1 = ('请输入一种披萨配料,输入‘quit’后会退出程序,请输入:')
while True:
msg = input(msg1)
if 'quit' in msg:
break
else:
print('我们会在比萨中添加这种配料: ' + msg)
7-5 电影票
while True:
age = int(input("请输入用户年龄:"))
if age < 3:
print("该用户免费")
elif 3 <= age < 12:
print("该年龄段用户收费的是10美元")
else:
print("该年龄段用户收费的是15美元")
7-6 三个出口
active = input("请输入你的年龄:")
while True:
age = int(input("请输入用户年龄:"))
if age < 3:
print("该用户免费")
elif 3 <= age < 12:
print("该年龄段用户收费的是10美元")
else:
print("该年龄段用户收费的是15美元")
if active == "quit":
break
7-7 无限循环
while True:
print("超最帅的你信不信(滑稽狗头)")
7-8 熟肉店
sandwich_orders = ['s1','s2','s3','s4']
finished_sandwiches = []
act = True
while act:
if int(len(sandwich_orders)) != 0:
cu_sw = sandwich_orders.pop()
finished_sandwiches.insert(0,cu_sw)
else:
act = False
print(finished_sandwiches)
7-9 五香烟熏牛肉卖完了
sandwich_orders = ["a", "b", "pastrami", "c", "pastrami", "d", "pastrami"]
print("五香熏牛肉卖完啦")
while "pastrami" in sandwich_orders:
sandwich_orders.remove("pastrami")
for i in sandwich_orders:
print(i)
7-10 梦想的度假胜地
while True:
name = input("请输入你的姓名:")
address = input("你想要去世界上的哪个地方:")
if address == 'quit' or name == 'quit':
break
else:
print("%s 想要去%s 旅行 " % (name, address))