Formatted Output - Floating Point Numbers

David Marshall maximum_hops at yahoo.co.uk
Sat Nov 16 16:21:19 EST 2002


Im new to python and I was wondering if anybody could tell me how to
modify the output to only obtaiu 2 decimal places.

the section of my program that needs modification

display.divide(57,7) # I only want 2 decimal places returned

I have a module called display and my function divide() returns the
result of the two numbers divided. However, I only want this number to
two decimal places.

I have tried: round(display.divide(57,7) [,2])
But this results in an error message saying invalid syntax


Any help would be much appreciated



More information about the Python-list mailing list