What is the use of the round () function in Python
This article introduces what is the use of the round () function in Python, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Description
The round () method returns the rounded value of the floating point number x.
Grammar
The following is the syntax of the round () method:
Round (x [, n]) parameter
X-numeric expression.
N-- a numeric expression that represents the number of places from the decimal point.
Return value
Returns the rounded value of the floating point number x.
Example
The following shows an example of using the round () method:
Example #! / usr/bin/pythonprint "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)
The output result of the above instance is as follows:
Round (80.23456, 2): 80.23round (100.000056, 3): 100.0round (- 100.000056, 3):-100.0 about the usefulness of the round () function in Python is shared here. I hope the above content can be helpful to everyone and learn more knowledge. If you think the article is good, you can share it for more people to see.