How to show percentage

Bill Mill bill.mill at gmail.com
Thu Sep 22 14:31:55 EDT 2005


You need to convert 1 or 3 to a float. How about:

>>> def pct(num, den): return (float(num)/den) * 100
...
>>> pct(1, 3)
33.333333333333329

Peace
Bill Mill
bill.mill at gmail.com

On 22 Sep 2005 10:51:43 -0700, Sen-Lung Chen
<slchen at slugger.ee.nthu.edu.tw> wrote:
> 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 %
>  Thanks
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list