[Tutor] Percentage

Pujo Aji ajikoe at gmail.com
Mon Nov 7 14:59:14 CET 2005


don't forget to use dot or converge into float.

perc = 42./250
or
perc = float(42)/250

otherwise:
it is treated as integer.

pujo

On 07 Nov 2005 11:50:05 -0200, Jorge Godoy <godoy at ieee.org> wrote:
>
> Johan Geldenhuys <johan at accesstel.co.za> writes:
>
> > What is the syntax if I want to work out what percentage 42 is out of
> 250?
>
> If you want it as a factor to multiply / divide by something:
>
> perc = 42/250
>
> If you want it to "read" as percentage:
>
> perc_100 = (42/250)*100
>
>
> Sds,
> --
> Jorge Godoy <godoy at ieee.org>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20051107/c12374fd/attachment.html


More information about the Tutor mailing list