嵌套字典|python_Python | 如果不是,则使用嵌套,根据销售额计算折扣

嵌套字典|python

Input same amount and calculate discount based on the amount and given discount rate in Python.

输入相同的金额,并根据Python中的金额和给定的折扣率计算折扣。

The discount rates are:

折扣率是:

    Amount       Discount
    0-5000          5%
    5000-15000      12%
    15000-25000     20%
    above 25000     30%

Program:

程序:

# input sale amount 
amt = int(input("Enter Sale Amount: "))

# conditions to check amount and get discount
if(amt>0):
    if amt<=5000:
       disc = amt*0.05
    else:
        if amt<=15000:
            disc=amt*0.12
        else:
            if amt<=25000:
                disc=0.2 * amt
            else:
                disc=0.3 * amt
    
    # printing discount and net payable amount 
    print("Discount : ",disc)
    print("Net Pay  : ",amt-disc)
else:
    print("Invalid Amount")

Output

输出量

Enter Sale Amount: 22000
Discount :  4400.0
Net Pay  :  17600.0


翻译自: https://www.includehelp.com/python/calculate-discount-based-on-the-sale-amount-nested-if-else.aspx

嵌套字典|python

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值