None???

David Eppstein eppstein at ics.uci.edu
Sun Sep 21 14:13:47 EDT 2003


In article <3F6D68AA.9070603 at aon.at>, Gregor Lingl <glingl at aon.at> 
wrote:

> >>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:
...
> This comes from using integer-constants together with
> inputting integers, which causes the /-operator to
> perform integer division.

Arguably, any code that uses / with integer arguments is now buggy, 
because it will produce different results in different Python versions.  
You should either use // (integer division) or force floating point 
division (e.g. by changing the expression to income*percent/100.0).

-- 
David Eppstein                      http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science




More information about the Python-list mailing list