September 5th, 2004, 09:27 PM
Can you round a number in python, like you do in elementary school?
I've searched and didn't see anything but maybe I just didn't look hard enough..
September 5th, 2004, 11:14 PM
You're looking for the built in round() function, from the docs:
I would give you a better example however i dont have access to Python right now sorry .
round( x[, n])
Return the floating point value x rounded to n digits after the
decimal point. If n is omitted, it defaults to zero. The result
is a floating point number. Values are rounded to the closest
multiple of 10 to the power minus n; if two multiples are
equally close, rounding is done away from 0 (so. for example,
round(0.5) is 1.0 and round(-0.5) is -1.0).
Hope this helps,
September 6th, 2004, 02:25 PM
Ahah, that is it. Thanks!
I just have to play around with that a little bit..