Skip to content

Instantly share code, notes, and snippets.

@ewindisch
Created October 25, 2012 20:21
Show Gist options
  • Save ewindisch/3955156 to your computer and use it in GitHub Desktop.
Save ewindisch/3955156 to your computer and use it in GitHub Desktop.
Obama Romney tax script
#!/usr/bin/env python
import sys
def calc_tax(agi, multiplier=1):
tax=0
table = {
0: [ 17400, 10 ],
17400: [ 70700, 15 ],
70700: [142700, 25 ],
142700: [ 217450, 28 ],
217450: [ 388350, 33 ],
388350: [ 999999999999999, 38 ]
}
for s,m in sorted(table.items()):
if agi < s:
break
taxable = min(agi, m[0]) - s
tax += taxable * (m[1]/100.0) * multiplier
print "Taxed on income %i-%i at %i%%" % (s, taxable, m[1] * multiplier)
return tax
income = int(sys.argv[1])
print "Calcuating for income: %s" % (income, )
obama = calc_tax(income, 1)
print "--------------------------------------"
print "Total amount taxed (Obama): $%i" % (obama, )
print "Percentage of AGI toward taxes: %i%%" % (obama/income * 100, )
print "--------------------------------------"
romney = calc_tax(income, .80)
print "--------------------------------------"
print "Total amount taxed (Romney): $%i" % (romney, )
print "Percentage of AGI toward taxes: %i%%" % (romney/income * 100, )
print "--------------------------------------"
print "--------------------------------------"
print "Difference: $%i - %i %%" % (obama - romney, 100 - romney / obama * 100.0)
print "--------------------------------------"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment