嵌套字典|python_Python | 如果不是,则使用嵌套,根据销售额计算折扣
生活随笔
收集整理的這篇文章主要介紹了
嵌套字典|python_Python | 如果不是,则使用嵌套,根据销售额计算折扣
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
嵌套字典|python
Input same amount and calculate discount based on the amount and given discount rate in Python.
輸入相同的金額,并根據(jù)Python中的金額和給定的折扣率計(jì)算折扣。
The discount rates are:
折扣率是:
Amount Discount0-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.05else:if amt<=15000:disc=amt*0.12else:if amt<=25000:disc=0.2 * amtelse: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
總結(jié)
以上是生活随笔為你收集整理的嵌套字典|python_Python | 如果不是,则使用嵌套,根据销售额计算折扣的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: javascript原型_使用JavaS
- 下一篇: python变量和常量_Python数学