How to round a floating point to nearest 10?

Edwin.Madari at Edwin.Madari at
Sun Aug 10 00:04:59 CEST 2008

>>> round(76.1, -2)
>>> round(76.1, -1)
>>> round(76.1)    

builtin function round,  will work for you......
Help on built-in function round in module __builtin__:
    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.

good luck..

-----Original Message-----
From: at
[ at]
On Behalf Of John Machin
Sent: Saturday, August 09, 2008 5:54 PM
To: python-list at
Subject: Re: How to round a floating point to nearest 10?

On Aug 10, 1:19 am, Mensanator <mensana... at> wrote:
> On Aug 9, 6:31 am, Will Rocisky <geekm... at> wrote:
> > I want my 76.1 to be rounded to decimal 80 and 74.9 to decimal 70.
> > How can I achieve that?
> >>> print '%.0e' % 74.9
> 7e+01
> >>> print '%.0e' % 76.1
> 8e+01

>>> print '%.0e' % 176.1

Giving the Subject ("How to round a floating point to nearest 10?"),
there's a strong presumption that the OP would want the answer to be
180, not 200.

The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure.  If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof.  Thank you.

More information about the Python-list mailing list