Python Forum
How to calculate tax with a variable input and if else
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to calculate tax with a variable input and if else
#1
The following is a lab taken from the course on python, which is what I am having difficulty with:

Estimated time 10-15 minutes Level of difficulty Easy/Medium Objectives Familiarize the student with: • using the if-else instruction to branch the control path; • building a complete program that solves simple real-life problems.

Scenario Once upon a time there was a land - a land of milk and honey, 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 for short) had to be paid once a year, and was evaluated using the following rule:

•if the citizen's income was not higher than 85,528 thalers, the tax was equal to 18% of the income minus 556 thalers and 2 cents (this was the so-called tax relief); •if the income was higher than this amount, the tax was equal to 14,839 thalers and 2 cents, plus 32% of the surplus over 85,528 thalers. Your task is to write a simple "tax calculator" - it should accept one floating-point value: the income. Next, it should print the calculated tax, rounded to full thalers. There's a function named round which will do the rounding for you - you'll find it in the skeleton code below. Note: this happy country never returns money to its citizens. If the calculated tax is less than zero, it only means no tax at all (the tax is equal to zero). Take this into consideration during your calculations. Look at the code below - it only reads one input value and outputs a result, so you need to complete it with some smart calculations. Test your code using the data we've provided.

My proposed solution is:

#If tax is less than or equal to 85,528 tax is 18% of income - 556.02.          
#If tax is more than 85,528, tax is 14,839.02 plus 32% of surplus above     85,528.

income = float(input("Enter the annual income: "))
if income <= 85528:
        tax = (income-556.02)*0.18
        # Brackets are to make it do those sums first
    else:
        tax = (income-85528)*0.32 + 14839.02
        # Brackets are to make it do those sums first
tax = round(tax,0)
print("The tax is:", tax)
but when i execute it i have not the right result as output
can you help me to solve it please
likes this post
Reply


Messages In This Thread
How to calculate tax with a variable input and if else - by afefDXCTN - Aug-14-2020, 06:27 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] How to calculate tax with a variable input and if else rokemas 1 2,124 Dec-28-2020, 06:53 AM
Last Post: buran
  New to Python - tiny coding assistance on user input function and assign to variable Mountain_Duck 1 2,511 Mar-23-2019, 06:54 PM
Last Post: Yoriz
  How to make a dynamic variable based on input loltylerdowney 3 3,793 Nov-30-2017, 09:49 PM
Last Post: loltylerdowney

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020