您的位置:首页 > 编程语言

高级编程技术第七次作业

2018-03-27 23:37 267 查看

第七章 用户输入和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)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: