Categories
Computer Science

Solving Problem: Tax Calculator

(If-elif control flow)

Once upon a time, there was a country inhabited by happy and prosperous people. The people paid taxes, of course – their happiness had limits. The most important tax, called the Personal Income Tax (PIT ), had to be paid yearly and was evaluated using the following rule:

  • If the citizen’s income was not higher than 85,528 INR, the tax was equal to 18% of the income minus 556 INR and 2 paisa (this was the so-called tax relief)
  • If the income was higher than this amount, the tax was equal to 14,839 INR and 2 paisa, plus 32% of the surplus over 85,528 INR.

Your task is to write a tax calculator.

  • It should accept one floating-point value: the income.
  • Next, it should print the calculated tax, rounded to the full INR. There’s a function named round() which will do the rounding for you – you’ll find it in the skeleton code in the editor.

Note: This happy country never returns money to its citizens. If the calculated tax is less than zero, it means there is no tax (the tax is zero). Take this into consideration during your calculations.

Sample input: 10000

Expected output: The tax is: 1244.0 INR

Sample input: 100000

Expected output: The tax is: 19470.0 INR

Sample input: 1000

Expected output: The tax is: 0.0 INR

Sample input: -100

Expected output: The tax is: 0.0 INR

Python
income = float(input("Enter the annual income: "))
tax = 0
if income <= 0:
tax = 0.0
elif 0 < income <= 85528:
tax = (18/100)*income - 556.2
elif income >= 85528:
tax = 14839.2 + (32/100)*(income - 85528)
else:
print("Invalid Input!")
tax = round(tax, 0)
print("The tax is:", tax, "INR")

Priyanka B.'s avatar

By Priyanka B.

Hello and welcome to my little corner of internet!! I am a techie. I am very interested to discover and innovate new advances in science and technology. Blogging is one of my hobbies which I think is very useful for broadening my knowledge horizons and help me grow my skills. Apart from blogging I have also little taste in artistic skills and literature, which can keep my writing and posts tangy.

Whether you stumbled in by chance or came here on purpose, I hope you find something that sparks your curiosity or makes you think a little deeper. Thanks for stopping by!!

Leave a comment