高级编程技术作业第四周 第七章课后练习

7-1  汽车租赁

car = input("What kind of car do you would like to rent?\n")
print("Let me see if I can find you a "+car)

7-2 

people = input("Please tell me how many people would come to have a dinner?\n")
people = int(people)
if people > 8:
    print("No available table")
else:
    print("OK")

7-4

while 1:
    pizza = input("Pizza ingredients:\n")
    if pizza == "quit":
        break
    else:
        print("We will add " + pizza + " to the pizza.") 

7-5

while 1:
    age = input("Your age?\n")
    if age == "quit":
        break
    age = int(age)
    if age < 3:
        print("free")
    elif age < 12:
        print("10 dollars")
    else:
        print("15 dollars")

7-8

sandwich_orders = ['Bacon Sandwich','Egg Sandwich','Cream Sandwich']
finished_sandwiches = []
while sandwich_orders:
    sandwich = sandwich_orders.pop()
    print("I made your " + sandwich + " sandwich.")
    finished_sandwiches.append(sandwich)
for sandwich in finished_sandwiches:
    print(sandwich)

7-10

vacation_places={}
client = True
while client:
    name = input("What's your name?\n")
    print("Hello, " + name)
    place = input("Where do you want to visit on your vacation?\n")
    another = input("Would you like to let another person respond?(yes/no)\n")
    vacation_places[name]=place
    if another == 'no':
        client = False
for name,place in vacation_places.items():
    print(name + " would like to visit " + place)

猜你喜欢

转载自blog.csdn.net/weixin_38742280/article/details/79732437