51,862 views
42 votes
42 votes
My assignment asks me to write a python program using if, elif, and else that takes a user's salary and calculates the tax based on three given criteria:

> for a salary between 10,000 and 20,000, tax is at 1%
> for a salary between 20,000 and 30,000, tax is at 2%
> for a salary greater than 30,000, tax is at 3%
> there is no tax otherwise

Criteria 1 and 2 seem to overlap because of 20,000. How can I solve this? Thanks!

User Intrications
by
2.6k points

1 Answer

11 votes
11 votes

Answer:

user_salary = int(input("Please Enter Your Salary : "))

if user_salary in range(10000, 20000):

print("Tax = ",int(user_salary/100*1))

elif user_salary in range(20000, 30000):

print("Tax = ",int(user_salary/100*2))

elif user_salary in range(30000, 40000):

print("Tax = ",int(user_salary/100*3))

else:

print("No Tax!")

Step-by-step explanation:

My assignment asks me to write a python program using if, elif, and else that takes-example-1
User Alla
by
3.4k points