>> Can someone till me how to get a two decimal precision every time?
print "%.2f" % (500/1000.0) # or... result = 500 / 1000.0 print "%.2f" % result Using 'new' style string formatting works too: print "{0:.2f}".format(500/1000.0) -Modulok- On 6/6/11, Michael bridges <micha_el2...@yahoo.com> wrote: > i saw it somewhere, but where? > > i want to 10 / 1000 and get 0.01 not 0 > if 1000 is made 1000.00 then 0.01 is printed > but that gives 500 / 1000.00 is 0.5 not 0.50 > > i might be thinking C# not python. > > can someone till me how to get a two decimal precision every time? > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor