[Tutor] round so only see 2 digits

Kojo Idrissa kojo@hal-pc.org
Sun, 03 Mar 2002 16:51:35 -0600


I've got a similar question:  How do I round a float to get rid of the 
leading zero before the decimal?  I've looked through the printf() args and 
I know how to have it print with any number of digits after the decimal, 
but I didn't find anything that dealt with removing the leading zero.

Maybe I missed it?  That's quite probable.

Thanks,

At 01:11 PM 3/3/2002 -0800, Sean 'Shaleh' Perry wrote:

>On 03-Mar-2002 Ron wrote:
> > How do I round a float so I will only see 2 digits after the decimal
> > point or however many I want?
> >
>
>The % operator takes the usual printf() arguments.  0.2%f means "unlimited
>before decimal, 2 after".  I belive this is documented in the python docs
>somewhere near the % operator.
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor

****************************
Kojo Idrissa

kojo@hal-pc.org
http://www.hal-pc.org/~kojo/
****************************