Python round() Function

Rounds numbers to the specified number of digits past the decimal point (default is 0 digits past the decimal point.)

Syntax

Python
round(number = None)

Parameters

ParameterDescription
number Required. A numeric value to be rounded off.
ndigits Optional. The number of decimal places to round the value. The default is None, meaning round to a whole number.

Example

Python
pi = 3.14159265359
print(round(pi))
print(round(pi, 2))

Output

3
3.14