float, '%.2f' help... please!
Darrell Gallion
darrell at dorb.com
Wed Jun 28 14:21:21 EDT 2000
I've had a bad record lately :)
But maybe I can get this one right.
>>> print round.__doc__
round(number[, ndigits]) -> floating point number
Round a number to a given precision in decimal digits (default 0 digits).
This always returns a floating point number. Precision may be negative.
>>> print '%.2f' % round(1.032, 2)
1.03
>>>
--Darrell
----- Original Message -----
From: <chibaA at TinterlogD.Tcom>
>
> I'm just kinda stuck for answers... I need to display a price -
> rounded up to the proper cent. I was using this line:
>
> print '%.2f' % (price+0.005)
>
More information about the Python-list
mailing list