Assignment-
- I need to make a program that calculates 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.
- The final statement should prompt the user for an income and then looks up the tax rate from the dictionary and prints the income, tax rate, and tax.
- Develop Python code that implements the program requirements.
Critique-
Thanks for your Module 3 Option #2 CT assignment submission.
Your program works properly to display the tax amount for an income but doesn't display the tax rate as is also required.
Here is my code:
def tax(income):
di={0:.1,1:.15,2:.2,3:.3} # rate are st
total_tax=0
if(income<500):
total_tax=di[0]*income
elif(income<1500):
total_tax=di[1]*income
elif(income<2500):
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')
Having troubles making it display that "tax rate"...Can you help?