# Python计算个人所得税

1.怎么计算个人所得税？

1

3

0

2

10

105

3

20

555

4

25

1055

5

30

2755

6

35

5505

7

45

13505

8%

20%

2%

6-10%

0.5-1%

1.5%

0.5-1.2%

0.80%

10-12%

10-12%

2.具体代码实现

```def calculator(salary):
'''
税后工资计算器
'''
point = 3500
yanglao_rate = 0.08
hospital_rate = 0.02
losejob_rate = 0.01
basemoney_rate = 0.2
five_one_money = salary * (yanglao_rate + hospital_rate + losejob_rate + basemoney_rate)
rest_money = salary - five_one_money - point
res_money = salary - five_one_money
if rest_money <= 1500:
res_money -= rest_money * 0.03
elif rest_money > 1500 and rest_money <= 4500:
tax_money = rest_money * 0.1
res_money -= (tax_money - 105)
elif rest_money > 4500 and rest_money <= 9000:
tax_money = rest_money * 0.2
res_money -= (tax_money - 555)
elif rest_money > 9000 and rest_money <= 35000:
tax_money = rest_money * 0.25
res_money -= (tax_money - 1005)
elif rest_money > 35000 and rest_money <= 55000:
tax_money = rest_money * 0.3
res_money -= (tax_money - 2755)
elif rest_money > 55000 and rest_money <= 80000:
tax_money = rest_money * 0.35
res_money -= (tax_money - 5505)
else:
tax_money = rest_money * 0.45
res_money -= (tax_money - 13505)
print('税前工资为：{0},税后工资为：{1}'.format(salary, res_money))

if __name__ == '__main__':
# calculator(one_salary)
salary_list = [10000, 14000, 15000, 16000, 18000, 25000, 80000, 100000]
for one_salary in salary_list:
calculator(one_salary)```

3.结果展示

70 篇文章11 人订阅

0 条评论