第七章作业

"""7.1 汽车租赁"""
car = input("What kind of car do you want to borrow: ")
print("Let me see if I can find you a " + car.title() + ".")




"""7.2 餐馆订位"""
total = input("How many clients are having a meal?\n")
if int(total) > 8:
print("There do no have empty desk.")
else:
print("There have some empty desks.")




"""7.3 10的整数倍"""
number = input("Please input a number: ")
if int(number)%10 == 0:
print(number + " is an integral multiple of 10.")
else:
print(number + " is not an integral multiple of 10.")



"""7.4 比萨配料"""
message = ""
while message != 'quit':
message = input("Please input an ingredient of pizza or input 'quit' to exit: ")
if message != 'quit':
print("We will add " + message + " into your pizza.")




"""7.5 电影票"""
while True:
message = input("Please input an age: ")
if message == 'quit':
break
message = int(message)
if message < 3:
print("The ticket is for free.")
elif message >= 3 and message < 12:
print("The ticket is cost 10 dollars.")
else:
print("The ticket is cost 15 dollars.")




"""7.6 三个出口"""
message = ""
print("Version1:")
while message != 'quit':
message = input("Please input an ingredient of pizza or input 'quit' to exit: ")
if message != 'quit':
print("We will add " + message + " into your pizza.")


print("\nVersion2:")
active = True
while active:
message = input("Please input an ingredient of pizza or input 'quit' to exit: ")
if message != 'quit':
print("We will add " + message + " into your pizza.")
else:
active = False


print("\nVersion3:")
while True:
message = input("Please input an ingredient of pizza or input 'quit' to exit: ")
if message != 'quit':
print("We will add " + message + " into your pizza.")
else:
break


"""7.7 无限循环"""
while 5 > 3:
print("You are right.")




"""7.8 熟食店"""
sandwich_orders = ['Cheese sandwich', 'Club sandwich', 'Dagwood', 'French dip', 'Peanut Butter and Jelly sandwich']
finished_sandwiches = []
for sandwich in sandwich_orders:
print("I made your " + sandwich + ".")
finished_sandwiches.append(sandwich)
for f_sandwich in finished_sandwiches:
print(f_sandwich)




"""7.9 五香烟熏牛肉"""
sandwich_orders = ['Cheese sandwich', 'pastrami', 'Club sandwich', 'pastrami', 'Dagwood', 'French dip', 'pastrami']
finished_sandwiches = []
print("Pastramies have been sold out!")
new_list = [i for i in sandwich_orders if i != 'pastrami']
sandwich_orders = new_list
for sandwich in sandwich_orders:
print("I made your " + sandwich + ".")
finished_sandwiches.append(sandwich)
for f_sandwich in finished_sandwiches:
print(f_sandwich)



"""7.10 梦想的度假胜地"""
vacationland = []
while True:
place = input("If you could visit one place in the world, where would you go?(input 'quit' to exit)\n")
if place != 'quit':
vacationland.append(place)
else:
break

猜你喜欢

转载自blog.csdn.net/ad_jadson/article/details/79703644