[Tutor] Rounding to n significant digits
Skipper Seabold
jsseabold at gmail.com
Wed Sep 2 04:00:06 CEST 2009
On Tue, Sep 1, 2009 at 9:44 PM, Richard Wagner<wagnerr at umich.edu> wrote:
> I'm fairly new to Python and am trying to find a simple way to round floats
> to a specific number of significant digits. I found an old post on this
> list with exactly the same problem:
>
Python 2.5.4 (r254:67916, Apr 4 2009, 17:56:17)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print round(2.555555, 2)
2.56
http://docs.python.org/library/functions.html#round
Skipper
More information about the Tutor
mailing list