Rounding to the nearest 5

MRAB google at mrabarnett.plus.com
Fri Jan 30 01:27:09 CET 2009


todpose at hotmail.com wrote:
> How can you make python round numbers to the nearest 5:
>  
> Example:
>  
> 3 => 0
> 8 => 10
> 23.2 => 20
> 36 => 35
> 51.5 => 50
>  
Divide by 5, round the result, then multiply by 5.



More information about the Python-list mailing list