Im building a basic income tax calculator but can't figure out how to do all the necessary calculations
if income in range(120001, 180000):
tax = income 29467
tax = income / 0.37
The given income if in this range needs to be $29,467 plus 37c for each $1 over $120,000 but i have no clue how to apply both calculations correctly
CodePudding user response:
why did you stated "tax" twice? then the first "tax" state will be wasted which means I shades with the latter "tax".
CodePudding user response:
My translation of the question is this:
If income is in the range 120,000 to 180,000 then add a constant amount of 29,467 then an additional 0.37 for every unit over 120,000.
If that is the case then:
def calculate_tax(income):
return 29_467 0.37 * (income - 120_000) if 120_000 < income < 180_000 else 0
print(f'{calculate_tax(150_000):,.2f}')
Output:
40,567.00
CodePudding user response:
You have income tax brackets.
0-120000. The rate is 29.467% 120001-180000 the rate is 37%. Based on your data
So for an income of 150000. The income tax is 120000*0.29467 (150000-120000)*0.37
CodePudding user response:
If I understood correctly, then try this option.
income = int(input('You income: '))
if income >= 120001 and income <= 180000:
tax = (29467 (income - 120001) * 0.37)
print(f'income = {income} , tax = {tax} dollars')
Solution:
You income: 123500
income = 123500 , tax = 30761.63 dollars