用python写一个北京市的个税计算器
1 #应纳税的钱:税前收入-5000元(起征点)-专项扣除(五险一金等) 2 #工资个税的计算公式为: 3 #个人所得税=应纳税的钱×适用税率-速算扣除数 4 ''' 5 1、全月应纳税所得额不超过3000元: 6 税率:3%; 速算扣除数(元):0 7 2、全月应纳税所得额超过3000元至12000元: 8 税率:10%; 速算扣除数(元):210 9 3、全月应纳税所得额超过12000元至25000元: 10 税率:20%; 速算扣除数(元):1410 11 4、全月应纳税所得额超过25000元至35000元: 12 税率:25%; 速算扣除数(元):2660 13 5、全月应纳税所得额超过35000元至55000元: 14 税率:30%; 速算扣除数(元):4410 15 6、全月应纳税所得额超过55000元至80000元: 16 税率:35%; 速算扣除数(元):7160 17 7、全月应纳税所得额超过80000元: 18 税率:45%; 速算扣除数(元):15160 19 ''' 20 #定义税前工资 21 Tax_salary = int(input("请输入你的工资:")) 22 if Tax_salary > 5000: 23 #应纳税的工资 24 Taxable_salary = Tax_salary - 5000 - Tax_salary * 0.22 25 26 if Taxable_salary <= 3000: 27 # 个人所得税 28 Personal_income_taxes = Taxable_salary * 0.03 - 0 29 30 elif Taxable_salary > 3000 and Taxable_salary <= 12000: 31 Personal_income_taxes = Taxable_salary * 0.1 - 210 32 33 elif Taxable_salary > 12000 and Taxable_salary <= 25000: 34 Personal_income_taxes = Taxable_salary * 0.2 - 1410 35 36 elif Taxable_salary > 25000 and Taxable_salary <= 35000: 37 Personal_income_taxes = Taxable_salary * 0.25 - 2660 38 39 elif Taxable_salary > 35000 and Taxable_salary <= 55000: 40 Personal_income_taxes = Taxable_salary * 0.3 - 4410 41 42 elif Taxable_salary > 55000 and Taxable_salary <= 80000: 43 Personal_income_taxes = Taxable_salary * 0.35 - 7160 44 45 elif Taxable_salary > 80000: 46 Personal_income_taxes = Taxable_salary * 0.45 - 15160 47 #五险一金 48 Five_one_gold = Tax_salary * 0.22 49 #实发工资 50 Net_pay = Tax_salary - Personal_income_taxes - Five_one_gold 51 52 print("本月实发工资(税后)为:{}".format(Net_pay)) 53 else: 54 print("本月实发工资(税后)为:{}".format(Tax_salary))
执行结果演示:
所思及所学
学而不思则罔,思而不学则殆!