NameError Traceback (most recent call last)
Cell In[1], line 29
24 tax_brackets = [(0, 36000, 0.03, 0), (36000, 144000, 0.1, 2520), (144000, 300000, 0.2, 16920),
25 (300000, 420000, 0.25, 31920), (420000, 660000, 0.3, 52920), (660000, 960000, 0.35, 85920),
26 (960000, float(‘inf’), 0.45, 181920)]
28 # 找到适用税率
—> 29 tax_rate = next(rate for income, _, _, _ in tax_brackets if taxable_income <= income)[2]
30 quick_deduction = next(rate for income, _, _, deduction in tax_brackets if taxable_income <= income)[3]
32 personal_income_tax = taxable_income * tax_rate - quick_deduction
Cell In[1], line 29, in <genexpr>(.0)
24 tax_brackets = [(0, 36000, 0.03, 0), (36000, 144000, 0.1, 2520), (144000, 300000, 0.2, 16920),
25 (300000, 420000, 0.25, 31920), (420000, 660000, 0.3, 52920), (660000, 960000, 0.35, 85920),
26 (960000, float(‘inf’), 0.45, 181920)]
28 # 找到适用税率
—> 29 tax_rate = next(rate for income, _, _, _ in tax_brackets if taxable_income <= income)[2]
30 quick_deduction = next(rate for income, _, _, deduction in tax_brackets if taxable_income <= income)[3]
32 personal_income_tax = taxable_income * tax_rate - quick_deduction
NameError: name ‘rate’ is not defined