Перейти к содержанию

Python round() built-in function

Python round() built-in function

From the Python 3 documentation Return number rounded to ndigits precision after the decimal point. If ndigits is omitted or is None, it returns the nearest integer to its input.

Examples

>>> round(1.4)
# 1
>>> round(1.5)
# 2
>>> round(2.1)
# 2
>>> round(2.9)
# 3
>>> round(2/3, ndigits=3)
# 0.667