Python中怎么计算个人所得税

本篇文章给大家分享的是有关Python中怎么计算个人所得税,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

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

Python中怎么计算个人所得税

对照个税税率表时,先计算出本月的应纳税所得额,再用此应纳税所得额与上表对照,就可以得到正确的税率和速算扣除数。

个人所得税的基数=应发工资-五险一金,若扣除五险一金后的余额<=3500,则不用缴纳个人所得税。

Python中怎么计算个人所得税

例:应发工资-五险一金-3500=1600,则个税=1600*0.1-105=55;应发工资-五险一金-3500=5000,个税=5000*0.2-555=445。

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.结果展示

Python中怎么计算个人所得税

以上就是Python中怎么计算个人所得税,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注行业资讯频道。