-1

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

bmo
  • 13
  • 3

4 Answers4

0

why did you stated "tax" twice? then the first "tax" state will be wasted which means I shades with the latter "tax".

Sprout
  • 11
  • 3
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 30 '22 at 05:29
0

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
DarkKnight
  • 19,739
  • 3
  • 6
  • 22
0

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

WombatPM
  • 2,561
  • 2
  • 22
  • 22
  • Of course you are not accounting for deductions, different rates for married vs single, different types of income – WombatPM May 30 '22 at 05:47
0

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
RiveN
  • 2,595
  • 11
  • 13
  • 26