I have a question??

Hung Jung Lu hungjunglu at yahoo.com
Thu Nov 13 04:01:22 EST 2003


philh at invalid.email.address (phil hunt) wrote in message news:<slrnbr3agu.hvk.philh at cabalamat.cabalamat.org>...
> On Tue, 11 Nov 2003 07:06:26 -0500, Ryan Silverwood <ryans at mad.scientist.com> wrote:
> >I want to write a python program which will calculate a person's net annual income after tax, given the following rules:
> >*The first 1500 is tax free
> >*any amount earned over £1500 and upto £35000 is taxed at 30%
> >*and amount earned over £35000 is taxed at 45%
> 
> infinity = 999999
> taxRates = [ [1500, 0], [35000-1500, 30], [infinity, 45] ]
> 
> def calcNetIncome(gross):
>    if youAreAskingUsenetToDoYourHomework:
>       taxRate = 100
>    net = gross * (100-taxRate)/100
>    return net

:)

Within integer precision,

bracket = round(gross)*[1,]
net = gross - 0.3*len(bracket[1500:35000]) - 0.45*len(bracket[35000:])

Hung Jung




More information about the Python-list mailing list