# Income tax calculator using Python

Hello friends! In this tutorial, we will build a Python program that can help us to calculate income tax based on given conditions. Remember that conditions are not fixed as income tax format can vary from country to country. Here in this program, I am using the Indian format of calculating income tax.

## Python program to calculate Income tax

With this simple Python program, I am going to explain to you how to make an income tax calculator with simple steps and not much complexity.

Let’s first understand the concept behind calculating income tax.

Every year in the time of the Budget session of Central Government, amendments are made in the income tax slabs. The below tax rates are only applicable for you if you do not wish to avail exemptions or deductions.

Here I am considering Indian Rupee (Rs) as the currency and taken conditions are:

1. If amount <= Rs. 2,50,000 then zero tax.
2. If amount <= Rs. 5,00,000 then 5% of total income exceeding Rs. 2,50,000
3. If amount <= Rs. 7,50,000 then Rs. 12500 + 10% of total income exceeding Rs. 5,00,000
4. If amount <= Rs. 10,00,000 then Rs. 37500 + 15% of total income exceeding Rs. 7,50,000
5. If amount <= Rs. 12,50,000 then Rs. 75000 + 20% of total income exceeding Rs. 10,00,000
6. If amount <= Rs. 15,00,000 then Rs. 125000 + 25% of total income exceeding Rs. 12,50,000
7. If amount > Rs. 15,00,000 then Rs. 187500 + 30% of total income exceeding Rs. 15,00,000

Let’s see how we can write a Python program for it:

Firstly we will start our program with a while loop where we can take inputs from the user about their income. Income should only be in a numerical format or else the program will show an error saying “Sorry, We didn’t understand that please enter taxable income as a number”

```while True:
try:

except ValueError:
print("Sorry, We didn't understand that please enter taxable income as a number")

continue
else:
break```

Now we will put if and else statements here to full fill our income tax calculating conditions as given below:

1. If income is less than or equals to Rs. 2,50,000 then tax will be zero.
2. If income is less than or equals to Rs. 5,00,000 then tax will be 5% of total income exceeding Rs. 2,50,000
3. If income is less than or equals to Rs. 7,50,000 then tax will be 10% of total income exceeding Rs. 5,00,000 with an additional cost of Rs. 12,500.
4. If income is less than or equals to Rs. 10,00,000 then tax will be 15% of total income exceeding Rs. 7,50,000 with an additional cost of Rs. 37,500.
5. If income is less than or equals to Rs. 12,50,000 then tax will be 20% of total income exceeding Rs. 10,00,000 with an additional cost of Rs. 75,000.
6. If income is less than or equals to Rs. 15,00,000 then tax will be 25% of total income exceeding Rs. 12,50,000 with an additional cost of Rs. 1,25,000.
7. If income is more than Rs. 15,00,000 then tax will be 30% of total income exceeding Rs. 15,00,000 with an additional cost of Rs. 1,87,500.

And so we can print the calculated income tax in Rupees.

```if income <= 250000:  #2 Lakh 50 thousand
tax = 0

elif income <= 500000: #5 Lakh
tax = (income - 250000) * 0.05

elif income <= 750000: #7 lakh 50 thousand
tax = (income - 500000) * 0.10 + 12500

elif income <= 1000000: #10 Lakh
tax = (income - 750000) * 0.15 + 37500

elif income <= 1250000: #12 lakh 50 thousand
tax = (income - 1000000) * 0.20 + 75000

elif income <= 1500000: #15 lakh
tax = (income - 1250000) * 0.25 + 125000

else:
tax = (income - 1500000) * 0.30 + 187500

print("you owe", tax, "Rupees in tax!")```

Output 1:

```Please enter your taxable income in india: 250000
you owe 0 Rupees in tax!```

Output 2:

```Please enter your taxable income in india: 750000
you owe 37500.0 Rupees in tax!```

Output 3:

```Please enter your taxable income in india: 2000000
you owe 337500.0 Rupees in tax!

```

I hope you enjoyed it. Now you can also calculate your income tax at home with this simple program by changing the conditions according to your country format. If you have any doubts then put them in the comments below.

### 2 responses to “Income tax calculator using Python”

1. Erica Faulkner says:

NEED HELP AND ASSISTANCE PLEASE AND THANK YOU…

I AM HAVING LOTS OF TROUBLE FIGURING THIS PROBLEM OUT…