欢迎光临散文网 会员登陆 & 注册

Python快递计费系统(简易)

2023-03-15 09:46 作者:梦江南阳  | 我要投稿

通过:

    if-elif 语句结构

    if 判断条件:

            要执行的代码

    elif 判断条件:

            要执行的代码

            ……

            else:

            要执行的代码

    d=input("请输入地区编号(华东地区01,华南地区02,华北地区03):")
    if d=='01':
        height=float(input('请输入快递重量(kg):'))
        if height<=2:
            print("该收取费用:",height*13)
        else:
            print("该收取费用:",height*13+(height-2)*3,'元')
     
    elif d=='02':
        height=float(input('请输入快递重量(kg):'))
        if height<=3:
            print("该收取费用:",height*12)
        else:
            print("该收取费用:",height*12+(height-2)*2,'元')
     
    elif d=='03':
        height=float(input('请输入快递重量(kg):'))
        if height<=3:
            print("该收取费用:",height*14)
        else:
            print("该收取费用:",height*14+(height-2)*4,'元')

 

转自网络 侵删

Python快递计费系统(简易)的评论 (共 条)

分享到微博请遵守国家法律