练习:while-break 循环+if-elif-else判断
题目:
发散:想要实现多次输入的效果,并且能够算出总票价,符合实际场景。
效果
代码:
print("welcom to our cinema")
age=''
prise=0
while True:
print("input everyone's age,end by input 'end'")
age=input()
if age!='end':
age_num=int(age)
if age_num<3:
prise+=0
elif age_num >12:
prise+=15
else:
prise+=10
else:
break
print("The total value of the movie ticket is $"+ str(prise))
涉及到的问题:
字符类型的转换、缩进的问题。