python123个人所得税计算器
时间: 2023-11-29 16:46:17 浏览: 144
个人所得税计算器.py
以下是一个简单的Python个人所得税计算器,根据用户输入的工资金额和社保费用计算应纳税额:
```python
def calculate_tax(salary, insurance):
# 计算应纳税所得额
taxable_income = salary - insurance - 3500
# 根据应纳税所得额计算税率和速算扣除数
if taxable_income <= 0:
tax_rate, quick_subtractor = 0, 0
elif taxable_income <= 1500:
tax_rate, quick_subtractor = 0.03, 0
elif taxable_income <= 4500:
tax_rate, quick_subtractor = 0.1, 105
elif taxable_income <= 9000:
tax_rate, quick_subtractor = 0.2, 555
elif taxable_income <= 35000:
tax_rate, quick_subtractor = 0.25, 1005
elif taxable_income <= 55000:
tax_rate, quick_subtractor = 0.3, 2755
elif taxable_income <= 80000:
tax_rate, quick_subtractor = 0.35, 5505
else:
tax_rate, quick_subtractor = 0.45, 13505
# 计算应纳税额
tax = taxable_income * tax_rate - quick_subtractor
# 计算税后工资
after_tax_salary = salary - insurance - tax
# 返回结果
return '{:.2f}'.format(after_tax_salary)
# 测试代码
salary = float(input('请输入工资金额:'))
insurance = float(input('请输入社保费用:'))
print('税后工资为:', calculate_tax(salary, insurance))
```
阅读全文