round

Round value to a given number of decimal digits.

Syntax

round(number, ndigits=None)

Parameters

NameDescription
numberInt | Float
Input number
Required · Positional or named
No default
ndigitsInt?
Decimal places to keep; negative values round tens, hundreds, and so on. None returns an integer. Halfway values round to the nearest even result.
Optional · Positional or named
Default: None

Returns

Int | Float — Rounded numeric value.

Example

ratio = round(0.87654, 2)
text(str(ratio))