"Sen-Lung Chen" <[EMAIL PROTECTED]> writes:

> Dear All:
>  I have a question of show percentage.
> For example ,I want to show the percentage of 1/3 = 33.33%
>
>  I use the 1*100/3 = 33
> it is 33 not 33.33 , how to show the 33.33 %

Python interprets '/' in an integer environment to return ints, not
floats. You can either turn one of your arguments into floats:

>>> float(1 * 100) / 3
33.333333333333336

This is going to change. Not sure when. You can ask for the new behavior:

>>> from __future__ import division
>>> 100 / 3
33.333333333333336

        <mike

-- 
Mike Meyer <[EMAIL PROTECTED]>                  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to