# 7-1 汽车租赁
car = input("请输入您想要的汽车:")
print(f"Let me see if I can find you a {car}")
# 7-2 餐厅订位
person_num = input("你们有多少人用餐?")
person_num = int(person_num)
if person_num > 8:
print("很抱歉,没有空桌了。")
else:
print("欢迎订餐,有空桌。")
# 7-3 10的倍数
number = input("请输入一个数字:")
number = int(number)
if (number % 10 == 0) and (number != 0):
print("这个数是10的倍数")
else:
print("这个数不是10的倍数")
# 7-4 披萨配料
message = " "
while message != 'quit':
message = input("请你输入您要加的配料:")
if message != 'quit':
print("我们会在披萨中加入" + message + "这种配料。")
# 7-5 电影票
prompt = "Enter 'quit' to end"
prompt += "\nPlease enter your age:"
while True:
age = input(prompt)
if age == 'quit':
break
else:
if int(age) < 3:
print("免费")
elif (int(age) >= 3) and (int(age) <= 12):
print("您的票价为10元。")
else:
print("您的票价为15元。")
# 7-6 三个出口
# 代码同7-5
# 7-7 无限循环
while True:
print("!!!")
# 7-8 熟食店
sandwich_orders = ['aaa', 'bbb', 'ccc']
finished_sandwiches = []
while sandwich_orders:
current_order = sandwich_orders.pop()
print(f"I made your {current_order} sandwich.")
finished_sandwiches.append(current_order)
print(f"\nfinished_sandwiches:")
for finished_sandwich in finished_sandwiches:
print(finished_sandwich)
# 7-9 五香烟熏牛肉(pastrami)卖完了
sandwich_orders = ['pastrami', 'aaa','pastrami', 'bbb', 'ccc','pastrami']
print(sandwich_orders)
while 'pastrami' in sandwich_orders:
sandwich_orders.remove('pastrami')
print(sandwich_orders)
# 7-10 梦想的度假圣地
responses = {}
polling_active = True
while polling_active:
name = input("\nWhat is your name?")
response = input("If you could visit one place in the world, where would you go? ")
responses[name] = response
repeat = input("Would you like to let another person?(y/n)")
if repeat == 'n':
polling_active = False
print("\n---Poll Results ---")
for name,response in responses.items():
print(name + " would like to visit " + response + ".")