[Tutor] floats

Jerry Hill malaclypse2 at gmail.com
Fri Dec 3 20:02:08 CET 2010


On Fri, Dec 3, 2010 at 1:52 PM, Christopher Spears
<cspears2002 at yahoo.com> wrote:
>>>> float_a = 1.16667
>
> However, I want to pass the value of float_a to float_b, but I want the float to be accurate to two decimal points.

Use the built-in round() function, like this:

>>> a = 1.16667
>>> print a
1.16667
>>> b = round(a, 2)
>>> print b
1.17


-- 
Jerry


More information about the Tutor mailing list