Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


The Python round() function returns specified number rounded to the specified number of decimal places.

Syntax

round(number, n)

Parameters

number Required. A number.
n Optional. number of decimal places to use for rounding the number. default is 0.

Example: Absolute value of a number

In the below example, round() function returns a given number rounded to the specified number of decimal places.

MyNumber = 3.1428
print(round(MyNumber))

MyNumber = 3.1428
print(round(MyNumber, 2))

The output of the above code will be:

3
3.14

❮ Python Built-in Functions