id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

tax_time


This function calculates the amount of tax you owe. (If it returns a negative number, you get a tax refund!) The parameters are how much you earn and how much tax has already been taken from your earnings (withheld). To figure the tax,
- subtract $5000 from the income. (You pay no tax on the $5000.)
- then take 15% of this smaller amount. This is your tax due.
- the difference between the tax due and withheld is the extra tax payment you have to make (if the number is positive) or the refund you will be getting (if the number is negative). In either case, the function returns this last number.
For example, let's consider someone earning $40,000 who has already had $6,000 withheld. $40,000 - $5,000 leaves $35,000 which is subject to tax of 15% and this gives a tax due of $5,250. Since the government already took $6,000, the difference is ($5,250 - $6,000). Since the result, - $750, is negative, it means this person will get a $750 refund.
Use the round() function to round the tax due to the nearest dollar before returning it. (The round function turns 3.2 into 3.0, so use int() after round!)


tax_time(55000, 6500) → 1000
tax_time(105000, 0) → 15000
tax_time(15000, 2000) → -500

...Save, Compile, Run (ctrl-enter)

def tax_time(income, withheld):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 100

Copyright Nick Parlante 2017 - privacy