Skip to content

Instantly share code, notes, and snippets.

@ford-prefect
Last active February 1, 2017 10:32
Show Gist options
  • Save ford-prefect/d042c9d5a1795ed752dccf60dce20315 to your computer and use it in GitHub Desktop.
Save ford-prefect/d042c9d5a1795ed752dccf60dce20315 to your computer and use it in GitHub Desktop.
income tax plotter
import matplotlib.pyplot as plt
import numpy as np
def tax(income):
income *= 1000
tax = 0
taxable = income
# 0-2.5L - 0%
if taxable < 250000:
return 0
# 2.5-5L - 5%
taxable -= 250000
if taxable >= 0:
tax += min(taxable, 250000) * 0.05
# 5-10L - 20%
taxable -= 250000
if taxable > 0:
tax += min(taxable, 500000) * 0.20
# >10L - 30%
taxable -= 500000
if taxable > 0:
tax += taxable * 0.30
# >1Cr - 12% surcharge (subject to marginal relief)
if income > 10000000:
if (income - 10000000) > ((tax * 1.12) - (tax * 1.1)):
tax *= 1.12
else:
tax = tax * 1.1 + (income - 10000000)
# >50L - 10% surcharge (subject to marginal relief)
elif income > 5000000:
if (income - 5000000) > (tax * 0.1):
tax *= 1.1
else:
tax += (income - 5000000)
# 3% edu cess
tax *= 1.03
return tax / 1000
t = np.arange(0, 12000, 1)
s = map(tax, t)
plt.plot(t, s)
plt.xlabel('income (1000s)')
plt.ylabel('tax (1000s)')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment