import sys BANDS = { 19400: 0.0, 37000: 19.0, 80000: 32.5, 180000: 37.0, } def calc(income): super_amount = income * (10.0/100.0) taxable_income = income - super_amount last_band_start = 0 tax_total = 0 max_band_reached = False print '\nNet income: %d \n'\ 'Superannuation @10 pct: %d \n'\ 'Taxable income: %d\n' % (income, super_amount, taxable_income) for band_limit, percent in BANDS.iteritems(): if max_band_reached: break msg = 'Band: {start} - {finish}, rate: {percent}, '.format( start=last_band_start+1, percent=percent, finish=band_limit) if band_limit >= income: band_taxable_amount = taxable_income - last_band_start max_band_reached = True else: band_taxable_amount = band_limit - last_band_start tax = band_taxable_amount * (percent/100.0) tax_total = tax_total + tax last_band_start = band_limit print msg + 'taxed amount: %d, tax: %d' % (band_taxable_amount, tax) medicare_levy = taxable_income * (2.0/100.0) net_income = int(income - tax_total - super_amount - medicare_levy) print '\n====================\n'\ 'Gross income: %d \n'\ 'Super: %d \n'\ 'Taxable income: %d \n'\ 'Medicare levy: %d \n'\ 'Total tax: %d \n'\ 'Income after tax, super and Medicare levy: %d \n\n'\ '=========================================\n'\ 'Net Monthly income: $%d \n'\ '=========================================\n'\ '\nEffective Hourly rate (40 hours/week): $%s/hour\n'\ '\nEffective Daily rate ( 5 days/week): $%s/day\n' % (income, super_amount, taxable_income, medicare_levy, tax_total, net_income, net_income/12, (net_income/12)/(40 * 4), (net_income/12)/(5 * 4)) if __name__ == '__main__': try: gross_amount = eval(sys.argv[1]) except: # Assume 4 weeks public holidays + sick + annual leave working_weeks_per_year = 48 working_days_per_month = 5 daily_rate = 650 gross_amount = daily_rate * working_weeks_per_year * working_days_per_month print 'Using gross amount: %d' % gross_amount calc(gross_amount)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question