第七章作业
2018-03-26 20:32
260 查看
"""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
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
相关文章推荐
- 第四周作业——第七章
- LDD 第七章 学习要点和作业
- 第七章作业
- [置顶] CSAPP第七章家庭作业参考答案
- 第四周作业——第七章动手试一试
- RFID第七章作业
- 【HW】 第七章作业 2018.3.26
- 【高编作业】第七章课后题
- 家庭作业(第二章、第三章、第七章、第八章)
- 作业 1 熟悉C语言编程环境第七章
- 第七章作业
- The C++ Programming Language 第七章 作业
- Java作业第七章(还是刷分篇)
- 高级编程技术作业第四周 第七章课后练习
- 《Java数据结构和算法》第二版 Robert lafore 编程作业 第七章
- python从入门到实践第七章的练习题作业
- RFID第七章作业——物联网1122-08黄炜彬
- 【RFID第四次作业】第七章课后习题
- Python第七章课后作业
- 第七章作业3