# -*- coding:utf-8 -*-
#li hongliang 2020年06月02日
#while 循环简介
#7-5 电影票:有家电影院根据观众的年龄收取不同的票价:不到3 岁的观众免费;
#3~12 岁的观众为10 美元;超过12 岁的观众为15 美元。请编写一个循环,在其中询问用户的年龄,并指出其票价。
prompt = "How old are you? "
active = True
while active:
age = input(prompt)
age = int(age)
if age < 3:
print(str(age)+" :Less than "+"3 years old Free movies")
elif 3 <= age <= 12:
print(str(age)+" :syears old 10 dollars for the audience")
elif age >12:
print(str(age)+": $15 for viewers over 12 years old")
else:
continue
prompt = "How old are you? "
age = 1
while age != 0: #while True:
age = input(prompt)
age = int(age)
if 0 < age < 3:
print("Less than "+"3 years old Free movies")
elif 3 <= age <= 12:
print("years old 10 dollars for the audience")
elif age >12:
print("$15 for viewers over 12 years old")
#continue #继续循环,不执行下面的代码
#else:
#print(age)
7-5 while 循环简介
最新推荐文章于 2023-11-23 15:48:32 发布