The round() function returns a floating-point number of the specified number in a rounded version.
Example
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
print("round(4.3): ", round(4.3))
print("round(4.8): ", round(4.8))
print("round(4.5): ", round(4.5))
print("round(-1.8): ", round(-1.8))
Output:
round(4.3): 4
round(4.8): 5
round(4.5): 4
round(-1.8): -2
Syntax
round(x)
Parameters
Name | Description |
x | A numerical expression. |
Return Value
It returns a floating-point number that is a rounded version of the specified number.