None???

Gregor Lingl glingl at aon.at
Sun Sep 21 11:00:26 CEST 2003


Heather Coppersmith schrieb:

> 
>>weekly_income = income/52
> 
> 
>>def compute(income, percent):
>>    result = income*percent/100
>>    print result
> 
Additionally please notice, that your program will produce
incorrect and probably at first irritating results:

**** example output: ****

How much do you make a year after taxes? 5199

What percent of your income do you want to put aside? 1

Ok, Gregor Lingl

This is how much you should put away a week:
$ 0

****

This comes from using integer-constants together with
inputting integers, which causes the /-operator to
perform integer division.

A simple way to avoid this would be to use 52.0 and
100.0 instead of 52 and 100

Regards,
Gregor





More information about the Python-list mailing list