description
描述
请编写一个程序,根据用户输入计算个人所得税。
-
用户输入是个人薪金扣险所得。
(1)约定用户输入为以人民币元为单位的零或者正数。不要增加额外的提示信息。
(2)如果用户输入了负数,提示“请输入正数!”。其他错误输入可以不予处理。
-
计算应缴纳的税金(保留小数点后一位)。
我国的个人所得税采用“超额累进税率”计算方法,简化公式如下:
缴税 = (个人薪金扣险所得 – 个税免征额)* 税率
其中,个税免征额为5000元,税率根据应纳税额数量而不同,如下表所示:
输入格式
例1: 输入一个正数,不要增加额外的提示信息
输入输出示例
code
代码来源于老师给的答案
salary = eval(input())
amout = salary-5000 # 减去个税免征额
tax = 0
if salary < 0:
print("请输入正数!")
else:
if amout < 0:
tax = 0
elif amout > 0 and amout <= 3000:
tax = amout*0.03
elif amout > 3000 and amout <= 12000:
tax = amout*0.1
elif amout > 12000 and amout <= 25000:
tax = amout*0.2
elif amout > 25000 and amout <= 35000:
tax = amout*0.25
elif amout > 35000 and amout <= 55000:
tax = amout*0.3
elif amout > 55000 and amout <= 80000:
tax = amout*0.35
else:
tax = amout*0.45
print("{:.1f}".format(tax)) # 保留一位小数