python编程 从入门到实践 第七章 课后习题(7-1~7-10)

## 动手试一试
# 7-1 汽车租赁
car=input("let me see if i can find you a sybaru.")
print(car)

# 7-2 餐厅订位
food=input("how many people? ")
food=int(food)
if food>8:
    print("there are not enough seats .")
else:
    print("there are seats. ")

# 7-3 10的整数倍
number=input('please enter a number: ')
number=int(number)
if number % 10 == 0:
    print(str(number)+" yes 10 ! ")
else:
    print(str(number)+" no,10 ! ")

##  动手试一试
#7-4 披萨配料
prompt="please enter a kind pizza"
prompt+="\n quit to end :"
while True:
    message = input(prompt)
    if message=="quit":
        break
    else:
        print("we will put the "+message)

# 7-5 电影票
prompt="please enter your age: "
while True:
    message=int(input(prompt))
    if message<3:
        print("your ticket is free. ")
    elif message<=12 and message>=3:
        print("your ticket is $10. ")
    elif message>12:
        print("your ticket is $15. ")
    else:
        print("wrong input")
        break
#7-6 三个出口

#7-7 无限循环
x=1
while x<=3:
    print(x)

##动手试一试
#7—8 熟食店
sandwich_orders=['apple','banana','pear']
finished_sandwiches=[]
while sandwich_orders:
    current_order=sandwich_orders.pop()
    print("i made your "+current_order+' sandwich . ')
    finished_sandwiches.append(current_order)
for finished_sandwich in finished_sandwiches:
    print(finished_sandwich)

# 7-9 五香烟熏牛肉
sandwich_orders=['apple','pastrami','banana','pastrami','pear','pastrami',]
print("the pastrami has been sold out. ")
while 'pastrami' in sandwich_orders:
    sandwich_orders.remove('pastrami')
print(sandwich_orders)

# 7-10 梦想的度假胜地

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值