# Demo entry 6785243

assignment

Submitted by Xu on Mar 14, 2019 at 13:13
Language: Python 3. Code size: 3.4 kB.

```# 2019 工资计算器
ALLCumulativeWithholdingTaxableIncome = [0, 36000, 144000, 300000, 420000, 660000, 960000]
AllTaxRates = [0.03, 0.10, 0.20, 0.25, 0.30, 0.35, 0.45] # 税率
AllQuickCalculationDeductions = [0, 2520, 16920, 31920, 52920, 85920, 181920] # 速算扣除数
TaxExemptionThreshold = 5000 # 起征点

# 累计应扣预缴纳税所得额

# 得到适用税率 和 速算扣除数
def get_withholding_tax_rate(CWTI): # 累计应扣预缴纳税所得额 cumulative_withholding_taxable_income
pos = 0
leng = len(ALLCumulativeWithholdingTaxableIncome)
while pos < leng:
if CWTI <= ALLCumulativeWithholdingTaxableIncome[pos]:
break
pos += 1
if pos == leng:
pos -= 1
return max([pos-1, 0])

# 累计预扣预缴税额
def Cumulative_withholding_tax_in_advance(CWTI, pos): # 累计应扣预缴纳税所得额 cumulative_withholding_taxable_income
withholding_tax_rate = AllTaxRates[pos]
quick_calculation_deduction = AllQuickCalculationDeductions[pos]
return CWTI * withholding_tax_rate - quick_calculation_deduction

# input
Salary = 0
last_Salary = 0;
month = int(input(" 纳税期数（月份 1—12）: ")) # 需计算的月份
flag = int(input(" 是否每月薪酬相同？（是输入1，否则输入0） : "))
if flag:
MonthlySalary = int(input(" 月薪 : ")) # 月薪
Salary = month * MonthlySalary
last_Salary = (month-1) * MonthlySalary
else :
print(" ~~请输入每个月的薪酬~~")
for i in range(month):
MonthlySalary = int(input(" 请输入 {} 月薪酬 : ".format(i+1)))
if i == month-1:
Salary = last_Salary + MonthlySalary
else :
last_Salary += MonthlySalary;
Social_insurance_premiums = int(input(" 专项扣除（各项社会保险费） : ")) # 各项社会保险费
special_additional_deduction = int(input(" 专项附加扣除 : ")) # 专项附加扣除
# 计算
print(" \n结果 : ")
# 本月累计应扣预缴纳税所得额
print(" {} 月累计应扣预缴纳税所得额 : {}".format(month, the_month_cumulative_withholding_taxable_income))

# 税率
# 本月适用税率
pos0 = get_withholding_tax_rate(the_month_cumulative_withholding_taxable_income)
withholding_tax_rate = AllTaxRates[pos0]
print(" 适用税率 ： %d%%" % (withholding_tax_rate*100))
last_pos = get_withholding_tax_rate(the_last_month_cumulative_withholding_taxable_income)

# 速算扣除数
the_month_QuickCalculationDeductions = AllQuickCalculationDeductions[pos0]
print(" 速算扣除数 : ", the_month_QuickCalculationDeductions)

# 累计预扣预缴税额