This is the P2PU Archive. If you want the current site, go to www.p2pu.org!

Learn Python the Hard Way

My recent threads

You haven't posted any discussions yet.

Recently updated threads

Exercise 5 : %f

Go back to: General discussion

%f returns  a decimal with 6 places.

i.e:
>>>print "%f"%5
5.000000

%.2f will return a number formatted to 2 decimals.

>>>print "$%.2f"%500
$500.00

Trent Branson's picture
Trent Branson
Tue, 2011-01-25 00:59

>>> "%.2f"%5.456
'5.46'
>>> "%.2f"%5.999
'6.00'

That is the first time I've ever had python round off???