这些是税率:
Net chargeable Income($) Rate Tax($)
On the First 50,000 2%
On the Next 50,000 6%
On the Next 50,000 10%
On the Next 50,000 14%
Remainder 17%
这些是客户及其收入:
Client Total Income
Amy 45,000
Bob 80,000
Jane 135,000
Steve 187,500
Hovy 250,000
Will 313,000
我想编写代码来打印每个客户的 2019 年税款,如下所示:
{'Amy': 900.0, 'Bob': 2800.0, 'Jane': 7500.0, 'Steve': 14250.0, 'Hovy': 24500.0, 'Will': 35210.0}
我的代码是这样的:
income = {'Amy':45000, 'Bob':80000, 'Jane':135000, 'Steve':187500, 'Hovy':250000, 'Will':313000}
tax = {'Amy':0, 'Bob':0, 'Jane':0, 'Steve':0, 'Hovy':0, 'Will':0}
def question_11(income=income):
client_list=list(income.values())
for i in range(len(client_list)):
if client_list[i]<50000:
tax[i]=0
elif 100000>=client_list[i]>=50000:
tax[i]=1000+(client_list[i]-50000)*0.06
elif 150000>=client_list[i]>100000:
tax[i]=4000+(client_list[i]-100000)*0.1
elif 200000>=client_list[i]>150000:
tax[i]=9000+(client_list[i]-150000)*0.14
elif client_list[i]>200000:
tax[i]=16000+(client_list[i]-200000)*0.17
for name in tax.keys():
(tax.keys[i])=str(name)
for tax_num in tax.values():
(tax[i])=int(tax_num)
dict1={name:tax_num}
print(dic1)
该代码在执行错误时存在一些问题,但我确信计算税额的内部逻辑是正确的。你能给我一些指示吗?谢谢!