"""
Exercise 7-1:
汽车租赁
"""
car = input("What car do you want to rent? ")
print("Let me see if I could find you a %s" %car)
"""
Exercise 7-2:
餐馆订位
"""
person_numbers = int(input('How many people are in your team? '))
if person_numbers > 8:
print("I'm afraid that you will have to wait for a table")
else:
print('Please follow me and your table is ready.')
"""
Exercise 7-3:
10的整数倍
"""
num = int(input("Please input a number: "))
if num % 10 == 0:
print("The number %d is a multiple of ten.")
else:
print("The number %d isn't a multiple of ten.")
"""
Exercise 7-4:
披萨配料
"""
prompt = "\nWhat toppings do you want to add on your pizza?"
prompt += "\nEnter 'quit' when you are finished: "
while True:
topping = input(prompt)
if topping != 'quit':
print("I will add %s on your pizza." %topping)
else:
break
"""
Exercise 7-5:
电影票
"""
while True:
age = input("What is your age: ")
if age == 'quit':
break
age = int(age)
if age < 3:
print("The price you have to pay for is zero.")
elif age <= 12:
print("The price you have to pay for is 10 dollars.")
else:
print("The price you have to pay for is 15 dollars.")
"""
Exercise 7-8:
熟食店
"""
sandwich_orders = ['turkey', 'roast beef', 'grilled cheese']
finished_orders = []
while sandwich_orders:
current_sandwich = sandwich_orders.pop()
print("I will made your %s sandwich later." % current_sandwich)
finished_orders.append(current_sandwich)
print('')
for sandwich in finished_orders:
print("I have made a %s sandwich for you." %sandwich)
"""
Exercise 7-9:
五香烟熏牛肉卖完了
"""
sandwich_orders = ['turkey', 'pastrami', 'roast beef', 'pastrami', 'grilled cheese',
'pastrami']
finished_orders = []
print("I am sorry that we have sold out pastrami today.")
while 'pastrami' in sandwich_orders:
sandwich_orders.remove('pastrami')
print('')
while sandwich_orders:
current_sandwich = sandwich_orders.pop()
print("I will made a %s sandwich for you later." %current_sandwich)
finished_orders.append(current_sandwich)
print('')
for sandwich in finished_orders:
print('I have made a %s sandwich for you.' %sandwich)
"""
Exercise 7-10:
梦想的度假胜地
"""
prompt_name = "\nWhat's your name? "
prompt_place = "If you could visit one place in the world, "
prompt_place += "where would you go? "
answers = {}
while True:
name = input(prompt_name)
place = input(prompt_place)
answers[name] = place
quit = input("Anyone else?(Y/N)")
if quit == 'N' or quit == 'n':
break
print('')
for name, place in answers.items():
print("-%s would like to visit %s." %(name.title(), place.title()))