Python floor () function
description
floor () Returns the rounded integer.
grammar
The following is the syntax floor () method:
import math math.floor( x )
NOTE: floor () is not directly accessible, we need to import math module, invoke the method through static object.
parameter
- x - numeric expression.
return value
Returns the rounded down integer.Examples
The following shows an example of using 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 output 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.0