python编程:从入门到实践 第七章习题
# 7-1
name=input("输入您要租赁的汽车")
print(f"Let me see if I can find you a{name}")
# 7-2
number=input("请问有多少人用餐?")
number=int(number)
if number>8:
print("sorry!")
else:
print("welcome!")
# 7-3
number=input("请输入一个数字")
number=int(number)
if (number%10)==0:
print("这个数是10的整数倍")
else:
print("这个数不是10的整数倍")
# 7-4
message=''
while True:
message=input("输入馅料")
if message!='quit':
print(message)
else:
break
# 7-5
Flage=True
while Flage==True:
age=input("请输入您的年龄:")
if age=='quit':
break;
age=int(age)
if age<3:
print("免费")
elif 3<=age<=12:
print("10美元")
else:
print("15美元")
# 7-8
sandwich_orders=['金枪鱼三明治','法式开放三明治','牛油果三明治']
finished_sandwiches=[]
while sandwich_orders:
sandwich=sandwich_orders.pop()
print(f"I made your {sandwich}")
finished_sandwiches.append(sandwich)
for sandwich in finished_sandwiches:
print(sandwich)
# 7-9
sandwich_order=['金枪鱼三明治','法式开放三明治','牛油果三明治','pastrami','pastrami','pastrami']
print("pastrami had solved out!")
while 'pastrami' in sandwich_order:
sandwich_order.remove('pastrami')
for sandwich in sandwich_order:
if sandwich=='pastrami':
print("未删除!")
else:
print("已经全部删除了")
# 7-10
survey={}
while True:
name=input('输入您的名字')
place=input('输入您想去的地方')
survey[name]=place
repeat=input("是否还有其他输入?")
if repeat!='yes':
break
for people,palces in survey.items():
print(f"{people} would like to go {palces}")