Python Math floor() Method
Python Math floor(x) returns the lower rounded integer of a number, less than or equal to x.
Python Math floor() Syntax
Here is the syntax of the floor() method:
import math
math.floor( x )
Note: floor() is not directly accessible, you need to import the math module and call the method through a static object.
Python Math floor() Parameters
- x – The numeric expression.
Python Math floor() Return Value
Returns an integer less than or equal to x.
Python Math floor() Example
The following shows an example of using the floor() method.
#!/usr/bin/python3
import math
print ("math.floor(-45.17) : ", math.floor(-45.17))
print ("math.floor(100.12) : ", math.floor(100.12))
print ("math.floor(100.72) : ", math.floor(100.72))
print ("math.floor(math.pi) : ", math.floor(math.pi))
Output: