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: "))
# checking conditions and calculating discount
if(amt>0):
if amt<=5000:
disc = amt*0.05
elif amt<=15000:
disc=amt*0.12
elif amt<=25000:
disc=0.2 * amt
else:
disc=0.3 * amt
print("Discount : ",disc)
print("Net Pay : ",amt-disc)
else:
print("Invalid Amount")
Output
输出量
Enter Sale Amount: 30000
Discount : 9000.0
Net Pay : 21000.0
翻译自: https://www.includehelp.com/python/calculate-discount-based-on-the-sale-amount.aspx
python 金额计算