python编程:从入门到实践 第七章习题

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}")
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值