Chapters
Python114 chapters

ReferenceBuilt-in functions

round()

Rounds to the nearest value, breaking exact halves towards the even number.

Signature

round(number, ndigits=None)

Parameters

NameMeans
numberan int or float
ndigitshow 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

See also