income = float(input("your income: "))
if income <= 100000:
initialIncome = income * .5
elif income in range (100001,250000):
initialIncome = income * .10
elif income in range (250001,500000):
initialIncome = income * .15
elif income >= 500001:
initialIncome = income * .20
status = input("status (s,m,w,d) ")
if status == "S":
S = 10000
elif status == "M":
S = 20000
elif status == "W":
S = 10000
elif status == "D":
S = 30000
dependents = float(input("dependents num: "))
if dependents >= 5:
dependentsPrice = 50000
if dependents <= 5:
dependentsPrice = 10000 * dependents
totalTax = initialIncome - (status + dependents)
print(totalTax)
#Its not working #this is what I am trying to do
finding out the tax of a person and subtract some based on their status and dependents
my expected output is the user will enter its income then will multiply how much tax
#will be deducted and will also deduct some based on their status and how many #dependents
#they have.
*#Income: 500000
#Status: Married
#Dependents: 3
#Tax = 25000****
>Solution :
Code:
- You are using status in
totalTaxinstead ofS. - You must add
.upper()to convert all the input strings to upper case as you have used uppercase inif statements.
income = float(input("your income: "))
if income <= 100000:
initialIncome = income * .5
elif income in range (100001,250000):
initialIncome = income * .10
elif income in range (250001,500001):
initialIncome = income * .15
elif income >= 500001:
initialIncome = income * .20
# Here you must add upper to convert all the strings to upper case
status = input("status (s,m,w,d) ").upper()
if status == "S":
S = 10000
elif status == "M":
S = 20000
elif status == "W":
S = 10000
elif status == "D":
S = 30000
dependents = float(input("dependents num: "))
if dependents >= 5:
dependentsPrice = 50000 *dependents
if dependents <= 5:
dependentsPrice = 10000 * dependents
# Here status is string. I suppose you are trying to use S.
#here use dependsPrice
totalTax = initialIncome - (S + dependentsPrice)
print(totalTax)