In this tutorial, we’ll learn how to use the floor() method in Python.
floor() method in Python returns floor of x i.e., the largest integer not greater than x.
Syntax
1 2 3 4 |
import math math.floor(x) |
Parameters
x-numeric expression.
Returns
largest integer not greater than x.
Example
1 2 3 4 5 6 7 8 9 10 |
#!/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) |
1 2 3 4 5 6 7 |
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 |