python计算个人所得税
时间: 2023-10-11 18:14:20 浏览: 273
以下是一个简单的 Python 代码片段,用于计算个人所得税:
```python
income = float(input("请输入年收入:"))
taxable_income = income - 5000 # 免征额为5000元
if taxable_income <= 0:
tax = 0
elif 0 < taxable_income <= 3000:
tax = taxable_income * 0.03
elif 3000 < taxable_income <= 12000:
tax = taxable_income * 0.1 - 210
elif 12000 < taxable_income <= 25000:
tax = taxable_income * 0.2 - 1410
elif 25000 < taxable_income <= 35000:
tax = taxable_income * 0.25 - 2660
elif 35000 < taxable_income <= 55000:
tax = taxable_income * 0.3 - 4410
elif 55000 < taxable_income <= 80000:
tax = taxable_income * 0.35 - 7160
else:
tax = taxable_income * 0.45 - 15160
print("个人所得税为:{:.2f}元".format(tax))
```
这个代码片段将用户输入的年收入减去免征额5000元,然后根据税率表计算个人所得税。注意,这个税率表是适用于中国的个人所得税税率表,如果你所在的国家有不同的税率表,请根据实际情况进行修改。
阅读全文