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

高级编程技术作业 (七)

2018-03-30 23:50 246 查看
7-1 汽车租赁 :编写一个程序,询问用户要租赁什么样的汽车,并打印一条消息,如“Let me see if I can find you a Subaru”。

type_car = input("what kind of car do you want to rant?")print("Let me see if I can find you a " + type_car)7-2 餐馆订位 :编写一个程序,询问用户有多少人用餐。如果超过8人,就打印一条消息,指出没有空桌;否则指出有空桌。

number = input("how many people will join the party?")if int(number) > 8: print('we have no empty chair')else: print('we have enough chair')7-3 10的整数倍 :让用户输入一个数字,并指出这个数字是否是10的整数倍。

number = input("please input a number")if int(number) % 10 == 0: print('this number is a multiplier of 10')else: print('this number is not a multiplier of 10')7-5 电影票 :有家电影院根据观众的年龄收取不同的票价:不到3岁的观众免费;3~12岁的观众为10美元;超过12岁的观众为15美元。请编写一个循环,在其中询问用户的年龄,并指出其票价。

while True: age = input('please input your age') if (age == 'q'): break elif (0 < int(age) <= 3): print('free') elif (3 < int(age) <= 12): print('you shoule pay for 10 $') elif (int(age) > 12): print('you should pay for 15 $') else: print('invaild input')
7-10 梦想的度假胜地 :编写一个程序,调查用户梦想的度假胜地。使用类似于“If you could visit one place in the world, where would you go?”的提示,并编写一个打印调查
结果的代码块。

hoilday_place = []while True: place = input('If you could visit one place in the world, where would you go?') if place == 'q': break else: hoilday_place.append(place)for place in hoilday_place: print(place + ' ')
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  homework