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

In, Python,write a function that takes 0 parameters and asks the user for their

ID: 3783216 • Letter: I

Question

In, Python,write a function that takes 0 parameters and asks the user for their income over the past year. The function will then calculates their taxes according to the following (hypothetical!) scenario:  For an income of under $100,000, the tax rate is 30%. For an income of $100,000 or above, but under $200,000, the tax rate if 35%. For an income $200,000 or above but below $500,000, the tax rate is 40%. For an income $500,000 or above, the tax rate is 45%. You do not need to worry about the number of decimal places. When you read in the income, use casting to convert the string to a float. That is, do not use the 'eval()' function.

calc taxes What is your income? 50000 Your declared income is 50000.0 Your tax rate is 30.0 You owe 15000.0 calc taxes What is your income? 150000 Your declared income is 150000.0 Your tax rate is 35.0 You owe: 52500.0 calc taxes What is your income 200000 Your declared income is 200000.0 Your tax rate is 40.0 You owe 80000.0 calc taxes What is your income? 2000000 Your declared income is 2000000.0 Your tax rate is 45.0 You owe 900000.0

Explanation / Answer

income = float(input("What is your income ?"))
print "Your declared income is:",income
rate = 0.0
if income>=500000:
rate = 45.0
elif income>=200000:
rate = 40.0
elif income>=100000:
rate = 35.0
else:
rate = 30.0
print "Your tax rate is:",rate
print "You owe:",income*rate/100

====================

output:

====================

What is your income ?Your declared income is: 200000.0
Your tax rate is: 40.0
You owe: 80000.0