These three numbers 1.2, 0.0034, 56000
all have one thing in common: two digits of accuracy. Lets say I want to report computed bandwidth of several very different devices that range from kilobytes per second to gigabytes per second, all of which vary by up to %10. The easiest way for my readers to quickly grasp the results is for me to convert everything to a common unit (say MB/s), line up the decimal points,
1.2 0.0034 56000
and avoid printing extraneous digits; if my computed values are 1.193225, 0.00344791, and 56188.5622, then my readers only need to see the above - the rest is noise. Despite extensive formatting options for floating point numbers, Python doesn't seem to have a clean way to print numbers with a fixed-accuracy. What would be the best way to do this?
A note on scoring this question: I'll chose the best (ie. simple, understandable, elegant) answer over the first answer. No need to rush.