ReferenceBuilt-in functions
round()
Rounds to the nearest value, breaking exact halves towards the even number.
Signature
round(number, ndigits=None)Parameters
| Name | Means |
|---|---|
number | an int or float |
ndigits | how many decimal places to keep |
Returns
An int when ndigits is omitted, otherwise a float.
Example
Python
print(round(3.7))
print(round(3.14159, 2))
print(round(0.5), round(1.5), round(2.5))Output
4 3.14 0 2 2