My code needs to have the following elements calculate the


My code needs to have the following elements: calculate the weekly average tax withholding for a customer, given the following weekly income guidelines: Income less than $500: tax rate 10%; Incomes greater than/equal to $500 and less than $1500: tax rate 15%; Incomes greater than/equal to $1500 and less than $2500: tax rate 20%; Incomes greater than/equal to $2500: tax rate 30%. Store the income brackets and rates in a dictionary. Need a loop that prompts the user for an income, looks up the tax rate from the dictionary, and ***prints the income, tax rate, and tax***. The loop runs indefinitely until the user enters a loop termination sentinel. My code works correctly EXCEPT it does not print the "tax rate"(%) as required

def tax(income):

 di={0:10,1:15,2:20,3:30} 

 total_tax=0

 if(income<500):

  total_tax=di[0]*income

 elif(income<1500 and income >=500):

  total_tax=di[1]*income

 elif(income<2500 and income >=1500):

  total_tax=di[2]*income

 else:

  total_tax=di[3]*income

 return total_tax

print("Enter income to calculate tax.")

n=int(input('Enter income :'))

while(n!=-1):

 print("Calculated tax is : ","%.2f"%tax(n))

 n=int(input('Enter income :'))

print('Bye')

Solution Preview :

Prepared by a verified Expert
Business Management: My code needs to have the following elements calculate the
Reference No:- TGS02867557

Now Priced at $10 (50% Discount)

Recommended (95%)

Rated (4.7/5)