##### How to calculate tax with a variable input and if else
 How to calculate tax with a variable input and if else treed226 Unladen Swallow Posts: 1 Threads: 0 Joined: Jul 2021 Reputation: Jul-21-2021, 02:53 PM I know this thread is almost a year old and the last post is from several months ago, but I just joined the forum and was checking things out when I noticed this question. Not sure if it will help the OP or not, but hopefully it will help people in the future. It looked like most of the difficulty was with identifying when the tax should be 0.00 based on the scenario. I'm still relatively new to python so I'm not sure if there is a more efficient way to do this, but this can be solved accurately with nested if statements: ```income = float(input("Enter the annual income: ")) if income <= 85528: #income less than or equal to based on scenario tax = income * .18 - 556.02 #calculate tax based on input if tax <= 0: #if the tax is less than or equal to zero tax = 0.00 #tax is 0.00 else: tax = tax #otherwise tax is equal to tax else: tax = (income - 85528) * 0.32 + 14839.02 #income greater than 85528 based on scenario if tax <= 0: #same as above tax = 0.00 else: tax = tax tax = round(tax, 0) print("The tax is:", tax, "thalers")``` Reply

 Messages In This Thread How to calculate tax with a variable input and if else - by afefDXCTN - Aug-14-2020, 06:27 AM RE: How to calculate tax with a variable input and if else - by bowlofred - Aug-14-2020, 06:31 AM RE: How to calculate tax with a variable input and if else - by afefDXCTN - Aug-14-2020, 06:37 AM RE: How to calculate tax with a variable input and if else - by Gamo - Aug-14-2020, 06:51 AM RE: How to calculate tax with a variable input and if else - by bowlofred - Aug-14-2020, 06:56 AM RE: How to calculate tax with a variable input and if else - by afefDXCTN - Aug-14-2020, 07:50 AM RE: How to calculate tax with a variable input and if else - by shalinisamipillai - Feb-09-2021, 11:21 AM RE: How to calculate tax with a variable input and if else - by Serafim - Feb-09-2021, 09:45 PM RE: How to calculate tax with a variable input and if else - by Kivans - Mar-13-2021, 09:47 PM RE: How to calculate tax with a variable input and if else - by treed226 - Jul-21-2021, 02:53 PM

 Possibly Related Threads… Thread Author Replies Views Last Post [split] How to calculate tax with a variable input and if else rokemas 1 602 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 1,205 Mar-23-2019, 06:54 PM Last Post: Yoriz How to make a dynamic variable based on input loltylerdowney 3 1,960 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