(If-elif control flow)
Problem Statement:
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.
Test Data
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
Solution:
income = float(input("Enter the annual income: "))tax = 0if income <= 0: tax = 0.0elif 0 < income <= 85528: tax = (18/100)*income - 556.2elif income >= 85528: tax = 14839.2 + (32/100)*(income - 85528)else: print("Invalid Input!")tax = round(tax, 0)print("The tax is:", tax, "INR")
Output:

