# Python:Personal Programme for Practice

Good Evening Friends, I hope outside code is allowed on this forum.As for coding practice I am trying to make a programme for tax calculation.But it is not working. Following is the code for my programme

``````#Tax-Calc

# In come tax calculation
def calculate_tax(income):
if (income < 300000):
tax =(0)  #nil tax
elif(income > 300001) and (income < 500000):
tax = (0.1 * (300000 - income))
elif(income > 500001) and (income < 1000000):
tax = (0.2 * (1000000 - 300000 - income))
elif (income > 1000001):
tax = (0.3 * (1000001 - 300000 - income))
else:
pass
x = float(input("Enter Income :"))
print (calculate_tax (x))
``````

I am coding this on python 3.5.When ever I run the programme I get â€śNoneâ€ť result. Can you point my mistake.

You forgot to `return tax`.

also all these conditions can be shortenedâ€¦

``````def calculate_tax(income):
if  income < 300000:
tax =(0)  #nil tax
elif income < 500000:
tax = (0.1 * (300000 - income))
elif   income < 1000000:
tax = (0.2 * (1000000 - 300000 - income))
elif  income > 1000001:
tax = (0.3 * (1000001 - 300000 - income))
else:
pass

return tax
``````

Donâ€™t forget to account for an income of 1000000 or 1000001.

good point!
almost missed

1 Like

Thanks for heads up. I didnâ€™t thought about such scenario

1 Like