欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > python >内容正文

python

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

发布时间:2025/3/11 python 40 豆豆
生活随笔 收集整理的这篇文章主要介绍了 嵌套字典|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 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

总结

以上是生活随笔为你收集整理的嵌套字典|python_Python | 如果不是,则使用嵌套,根据销售额计算折扣的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。