Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

create 3 lists: name_list, income_list, tax_due_list They will start as empty li

ID: 640607 • Letter: C

Question

create 3 lists: name_list, income_list, tax_due_list They will start as empty lists, then you append data to each list. After you have computed the total tax and average tax, display each taxpayer's name, income and tax one line for each taxpayer.

Here is some code that might help.

def get_tax(yearly_income):

if yearly_income <= 5000:

return 0.0

elif yearly_income > 5000 and yearly_income < 15000:

return 100 + (yearly_income - 5000) * 0.010

elif yearly_income > 15000 and yearly_income < 50000:

return 100 + (yearly_income - 5000) * 0.015

elif yearly_income > 50000 and yearly_income < 250000:

return 100 + (yearly_income - 5000) * 0.020

elif yearly_income > 250000:

return 100 + (yearly_income - 5000) * 0.020

total_tax_paid = 0.0

total_payers = 0

while(1):

name = input("enter name of the tax payer: ")

income = float(input("enter salary: "))

tax = get_tax(income)

print(name, "has to pay", tax, "as income tax")

total_tax_paid += tax

total_payers += 1

again = input("enter another? (Y/N)?")

if again.lower() == 'n':

break

  

print(format(total_tax_paid, ',.2f'), 'was paid by', total_payers, 'person')

Explanation / Answer

def get_tax(yearly_income):
if yearly_income <= 5000:
return 0.0
elif yearly_income > 5000 and yearly_income <= 15000:
return 100 + (yearly_income - 5000) * 0.010
elif yearly_income > 15000 and yearly_income <= 50000:
return 100 + (yearly_income - 5000) * 0.015
elif yearly_income > 50000 and yearly_income <= 250000:
return 100 + (yearly_income - 5000) * 0.020
elif yearly_income > 250000:
return 100 + (yearly_income - 5000) * 0.020
  
def main():
total_tax_paid = 0.0
total_payers = 0
L = []
while(True):
name = input("enter name of the tax payer: ")
income = float(input("enter salary: "))
tax = get_tax(income)
total_tax_paid += tax
total_payers += 1
L.append([name, income, tax])
again = input("enter another? (Y/N)?")
if again.lower() == 'n':
break
print()
for i in L:
print(i[0], " has income of ", i[1], " and has to pay ", i[2], " as income tax")
print()
print(format(total_tax_paid, ',.2f'), ' was paid by ', total_payers, ' person(s)')
print('Average Tax: ', total_tax_paid / total_payers)

main()