Python floor() function
Description
floor() returns the floor integer of the number.
Syntax
The following is the syntax for the floor() method:
import math math.floor( x )
Note:floor() cannot be accessed directly; you need to import the math module and call the method via a static object.
Parameters
- x -- a numeric expression.
Return Value
Returns the floor integer of the number.Example
The following shows an example of using the floor() method:
#!/usr/bin/python import math # This will import math module 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(119L) : ", math.floor(119L) print "math.floor(math.pi) : ", math.floor(math.pi)
After running the above example, the output result is:
math.floor(-45.17) : -46.0 math.floor(100.12) : 100.0 math.floor(100.72) : 100.0 math.floor(119L) : 119.0 math.floor(math.pi) : 3.0Other extensions
Python Numbers