Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Speedy category for Friendly Number by Gondragos
from math import log
def friendly_number(number, base=1000, decimals=0, suffix='',
powers=['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']):
pid = number and min(int(log(abs(number),base)),len(powers)-1)
number = number/(base**pid)
number = round(number,decimals) if decimals else int(number)
return ('{:.{}f}{:s}{:s}').format(number,decimals,powers[pid],suffix)
Jan. 22, 2016