7-2 餐馆订位
num=input("How many people will have dinner?") if num > str(8): print("No available table.") else: print("There are available tables.")
7-5 电影票
while True: num=input("Please input your age:") num=int(num) if num < 3: print("Free of charge.") elif num < 12: print("10 dollars.") else: print("15 dollars.")7-6 三个出口
num=1 while num!=0: num=input("Please input your age,input 0 to quit") num=int(num) if num < 3: print("Free of charge.") elif num < 12: print("10 dollars.") else: print("15 dollars.")
active=True while active: num=input("Please input your age,input 0 to quit") num=int(num) if num==0: active=False elif num < 3: print("Free of charge.") elif num < 12: print("10 dollars.") else: print("15 dollars.")
while True: num=input("Please input your age,input quit to quit") if num=='quit': break num=int(num) if num==0: active=False elif num < 3: print("Free of charge.") elif num < 12: print("10 dollars.") else: print("15 dollars.")
7-8 熟食店
sandwich_orders=['tuna','pastrami','chicken'] finished_sandwiches=[] while sandwich_orders: current_sandwich=sandwich_orders.pop() print("I made you "+current_sandwich+" sandwich") finished_sandwiches.append(current_sandwich) print(finished_sandwiches)