python-round

Python Round

Example

Round a number to only two decimals:

x = round(5.765432)
print(x)

Definition and Usage

The round() function restores a skimming point number that is an adjusted form of the predetermined number, with the predefined number of decimals.

The default number of decimals is 0, implying that the capacity will return the closest whole number.

Syntax

round(number, digits)

Parameter Values

ParameterDescription
numberRequired. The number to be rounded
digitsOptional. The number of decimals to use when rounding the number. Default is 0

More Examples

Example

Round to the nearest integer:

x = round(5.76543)
print(x)