高级编程技术第七次作业

第七章 用户输入和while循环

7-1 汽车租赁

car = input("Which car do you want to buy?")
print ("Let me see if I can fond you a " + car)

7-2 餐馆定位

number = input("How many people will have the meal? ")
number = int(number)
if number > 8:
    print ("There are no available table for having meal")

7-3 10的整数倍

num = input("Please input a number: ")
num = int(num)
if num % 10 == 0:
    print ("The number is a multiplier of ten")
else:
    print ("The number is not a multiplier of ten")

7-4 比萨配料

while True:
    ingredient = input("Please input a pizza ingredient: ")
    if ingredient == "quit":
        break;
    print ("We will add the ingredient to your pizza")

7-5 电影票

while True:
    age = input("What is your age? ")
    age = int(age)
    if age <= 3:
        print ("Free")
    elif age <=12:
        print ("10 dollars")
    else:
        print ("15 dollars")

7-7 无限循环

print ("It is an infinite loop")
while True:
    number = input("Please input a number you like: ")
    print ("Your number is " + number)

7-8 熟食店

sandwish_orders = ["A_sandwish", "B_sandwish", "C_sandwish", "D_sandwish"]
finished_sandwish = []
while sandwish_orders:
    print ("I made your " + sandwish_orders[0])
    finished_sandwish.append(sandwish_orders[0])
    del sandwish_orders[0]
print ("All sanwishes have been finished")
print (finished_sandwish)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值