python个人税计算
时间: 2023-11-04 19:19:49 浏览: 47
以下是一个简单的 Python 代码示例,用于计算个人所得税:
```python
def calculate_tax(income):
# 计算应纳税所得额
taxable_income = income - 5000
# 根据税率表计算税金
if taxable_income <= 0:
tax = 0
elif taxable_income <= 3000:
tax = taxable_income * 0.03
elif taxable_income <= 12000:
tax = taxable_income * 0.1 - 210
elif taxable_income <= 25000:
tax = taxable_income * 0.2 - 1410
elif taxable_income <= 35000:
tax = taxable_income * 0.25 - 2660
elif taxable_income <= 55000:
tax = taxable_income * 0.3 - 4410
elif taxable_income <= 80000:
tax = taxable_income * 0.35 - 7160
else:
tax = taxable_income * 0.45 - 15160
# 计算税后收入
after_tax = income - tax
return {"income": income, "tax": tax, "after_tax": after_tax}
# 用法示例
income = 10000 # 月收入为 10000 元
result = calculate_tax(income)
print(result)
```
该代码根据中国个人所得税税率表计算应纳税所得额和税金,并计算税后收入。在计算应纳税所得额时,我们先将月收入减去 5000 元的基本扣除,然后根据税率表计算税金。最后,我们将税金从月收入中扣除,得到税后收入。
请注意,这只是一个简单的个人所得税计算示例,实际应用需要考虑更多因素,如社保、公积金等。