?7-1
car = input("which car do you want to lease? ")
print(f"Let me see if i can find you a {car}")
7-2
people = input("How many of you are there? ")
people = int(people)
if people <= 8:
print("Welcome!")
else:
print("sorry,We don't have any tables available.")
7-3
num = input("please input a number.And i will tell you if it is a multiple of 10: ")
num = int(num)
if num%10 == 0:
print("it is a multiple of 10.")
else:
print("sorry,it is not a multiple of 10.")
7-4
word = ""
while word != "quit":
word = input("Enter the pizza ingredients you want: ")
if word != "quit":
print(f"{word} will be added.")
?7-5
while True:
age = input("Your age: ")
if age == "quit":
break
age = int(age)
if age < 3:
print("You are free.ヽ(?゚▽゚)ノ")
elif age < 13:
print("Your ticket is 13.")
else:
print("Your ticket is 15")
7-6
#使用active,另外两项7-4 7-5均有使用
active = True
while active:
word = input("Enter the pizza ingredients you want: ")
if word != "quit":
print(f"{word} will be added.")
else:
active = False
7-7
active = True
while active:
print('1')
?7-8
Sandwich_orders = ['tuna', 'button', 'chicken']
finished_sandwich = []
while Sandwich_orders:
sandwich = Sandwich_orders.pop()
print(f"I made your {sandwich} sandwich.")
finished_sandwich.append(sandwich)
print(finished_sandwich)
7-9
Sandwich_orders = ['pastrami', 'tuna', 'button', 'pastrami', 'chicken', 'pastrami']
print("The pastrami was sold olt.")
while 'pastrami' in Sandwich_orders:
Sandwich_orders.remove('pastrami')
print(Sandwich_orders)
7-10
active = True
favorite_place = {}
while active:
name = input("what's your name? ")
place = input("If you could visit one place in the world,where would you go: ")
favorite_place[name] = place
ans = input("Is there anyone next?(yes/no)")
if ans == "no":
break
for name, place in favorite_place.items():
print(f"{name} favorite place is {place}")
|