7-5 while 循环简介

# -*- 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)





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值