Python round () function
description
round () method returns the rounded value of the floating-point number x.
grammar
The following is the syntax round () method:
round( x [, n] )
parameter
- x - numeric expression.
- n - numeric expression.
return value
Returns the rounded value of the floating-point number x.Examples
The following illustrates the use of round () method Example:
#!/usr/bin/python print "round(80.23456, 2) : ", round(80.23456, 2) print "round(100.000056, 3) : ", round(100.000056, 3) print "round(-100.000056, 3) : ", round(-100.000056, 3)
After running the above example output is:
round(80.23456, 2) : 80.23 round(100.000056, 3) : 100.0 round(-100.000056, 3) : -100.0