Rounding to the nearest 5

MRAB google at mrabarnett.plus.com
Thu Jan 29 19:27:09 EST 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