用Python实现请编写一个个税计算器,用户输入为应发工资薪金所得扣除五险一金后的金额,输出应缴税款和实发工资,结果保留小数点后两位。当输入数字小于0时,输出“error”
时间: 2023-04-01 22:01:56 浏览: 455
我可以回答这个问题。以下是 Python 实现个税计算器的代码:
salary = float(input("请输入应发工资薪金所得扣除五险一金后的金额:"))
if salary < :
print("error")
else:
taxable_income = salary - 500
if taxable_income <= :
tax =
elif taxable_income <= 300:
tax = taxable_income * .03
elif taxable_income <= 12000:
tax = taxable_income * .1 - 210
elif taxable_income <= 25000:
tax = taxable_income * .2 - 141
elif taxable_income <= 35000:
tax = taxable_income * .25 - 266
elif taxable_income <= 55000:
tax = taxable_income * .3 - 441
elif taxable_income <= 80000:
tax = taxable_income * .35 - 716
else:
tax = taxable_income * .45 - 15160
after_tax_salary = salary - tax
print("应缴税款为:{:.2f},实发工资为:{:.2f}".format(tax, after_tax_salary))
阅读全文