Python代码:
#Chapter 7 by szh 2018.3.26 print("\n7.1") car = input("Enter the car you want: ") print("Let me see if I can find you a " + car + '.') print("\n7.2") num = input("Enter the nnumber if people: ") if int(num) > 8: print("No empty table.") else: print("Have empty table.") print("\n7.3") num = input("Enter a number: ") if int(num) % 10 == 0: print("It's an integer multiple of 10") else: print("It isn't an integer multiple of 10") print("\n7.4") plzza_batching = [] while True: string = input("Enter the batching: ") if string.lower() == "quit": break plzza_batching.append(string) print(plzza_batching) print("\n7.8") sandwich_orders = ['Bocadillo', 'Doner Kebab', 'Torta'] finished_sandwiches = [] for sandwich in sandwich_orders: print(" I made your " + sandwich + " sandwich.") finished_sandwiches.append(sandwich) print(finished_sandwiches)
输出结果:
7.1 Enter the car you want: Subaru Let me see if I can find you a Subaru. 7.2 Enter the nnumber if people: 9 No empty table. 7.3 Enter a number: 10 It's an integer multiple of 10 7.4 Enter the batching: pork Enter the batching: tomato Enter the batching: quit ['pork', 'tomato'] 7.8 I made your Bocadillo sandwich. I made your Doner Kebab sandwich. I made your Torta sandwich. ['Bocadillo', 'Doner Kebab', 'Torta']