python计算个人所得税代码
时间: 2023-12-08 14:38:31 浏览: 193
Python实现的个人所得税计算器示例
以下是一个简单的Python计算个人所得税的代码,根据用户输入的工资金额进行计算:
```python
def calculate_tax(income):
# 应纳税所得额 = 工资金额 - 各项社会保险费 - 起征点(3500元)
taxable_income = income - 3500
# 根据应纳税所得额计算税率和速算扣除数
if taxable_income <= 0:
tax_rate = 0
quick_deduction = 0
elif taxable_income <= 1500:
tax_rate = 0.03
quick_deduction = 0
elif taxable_income <= 4500:
tax_rate = 0.1
quick_deduction = 105
elif taxable_income <= 9000:
tax_rate = 0.2
quick_deduction = 555
elif taxable_income <= 35000:
tax_rate = 0.25
quick_deduction = 1005
elif taxable_income <= 55000:
tax_rate = 0.3
quick_deduction = 2755
elif taxable_income <= 80000:
tax_rate = 0.35
quick_deduction = 5505
else:
tax_rate = 0.45
quick_deduction = 13505
# 应纳税额 = 应纳税所得额 × 税率 - 速算扣除数
tax = taxable_income * tax_rate - quick_deduction
return max(0, tax) # 税额不能为负数
income = float(input("请输入您的工资金额:"))
tax = calculate_tax(income)
print("您的个人所得税金额为:{:.2f}元".format(tax))
```
阅读全文