第七章作业

"""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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值