Python math.floor() Method
Python math.floor(x) The method rounds x down to the nearest integer.
math.ceil() The method rounds a number up to the nearest integer.
Syntax
The syntax of the math.floor() method is as follows:
math.floor(x)
Parameter Description:
- x -- required, a number. If x is not a number, a TypeError is returned.
Return Value
Returns an integer int representing the rounded-down number.
Example
The following example returns values rounded down to the nearest integer:
Example
Import the math package
import
math
Output the values rounded down to the nearest integer
(
math
.
floor
(
0.6
)
)
(
math
.
floor
(
1.4
)
)
(
math
.
floor
(
5.3
)
)
(
math
.
floor
(
5.3
)
)
(
math
.
floor
(
22.6
)
)
(
math
.
floor
(
10.0
)
)
Output result:
0
1
5
-6
22
10
Python math Module