用Python计算个人所得税的代码以及输出运行代码
时间: 2024-02-22 08:01:07 浏览: 168
py代码-输入一个包含若干自然数的列表,输出一个新列表,新列表中每个元素为原列表中 每个自然数的位数。例如输入[1,888,99,23456],输出[1,3,2,5]。
以下是用 Python 计算个人所得税的代码:
```python
# 输入月薪和年终奖金额
monthly_salary = float(input("请输入您的月薪:"))
year_end_bonus = float(input("请输入您的年终奖金额:"))
# 计算年收入
annual_income = monthly_salary * 12 + year_end_bonus
# 计算应纳税所得额
taxable_income = annual_income - 5000 * 12
# 计算税率和速算扣除数
if taxable_income <= 36000:
tax_rate = 0.03
deduction = 0
elif taxable_income <= 144000:
tax_rate = 0.1
deduction = 2520
elif taxable_income <= 300000:
tax_rate = 0.2
deduction = 16920
elif taxable_income <= 420000:
tax_rate = 0.25
deduction = 31920
elif taxable_income <= 660000:
tax_rate = 0.3
deduction = 52920
elif taxable_income <= 960000:
tax_rate = 0.35
deduction = 85920
else:
tax_rate = 0.45
deduction = 181920
# 计算个人所得税
tax = taxable_income * tax_rate - deduction
# 输出个人所得税
print("您的个人所得税为:{:.2f}元".format(tax))
```
运行代码后,会提示您输入月薪和年终奖金额,然后会输出计算出的个人所得税金额。例如,如果您的月薪为 10000 元,年终奖为 50000 元,运行代码后输出如下:
```
请输入您的月薪:10000
请输入您的年终奖金额:50000
您的个人所得税为:3120.00元
```
阅读全文