On Thu, Jan 29, 2009 at 7:26 PM, Tim Chase 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
>
> I'm not sure *any* rounding system will give those results.

def bogoround(n):
    n1 = n / 5.0
    return int(round(n1) if n1 % 2 > 1 else n1) * 5

best-I-could-do-ly y'rs,
-Miles
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to