How to round a floating point to nearest 10?

Daniel Klein danielk at featherbrain.net
Sat Aug 9 08:42:53 EDT 2008


On Sat, 9 Aug 2008 04:31:38 -0700 (PDT), Will Rocisky <geekmoth at gmail.com>
wrote:

>I want my 76.1 to be rounded to decimal 80 and 74.9 to decimal 70.
>How can I achieve that?

>>> for n in (74.9, 76.1):
	print int((n+5)/10)*10

70
80

Dan



More information about the Python-list mailing list