[Tutor] Help on float & round.
Greg Chapman
greg@gregmchapman.info
Wed Jun 11 00:55:03 2003
Ahh, someone who didn't suffer through c-style string formatting :)
I can't say that the manual has the clearest explanation
(http://www.python.org/doc/current/lib/typesseq-strings.html#l2h-154)
You don't need to round at all, just modify your print statement:
print "Current Price: %.2f" % (cp)
^^
the .2 specifies the number of digits to be included after the decimal
point, I believe that rounding happens automagically. Someone correct me if
I'm wrong.
greg