Easy Tutorial
❮ Python Func Input Ref Set Discard ❯

Python3 floor() Function

Python3 Numbers


Description

The floor(x) function returns the largest integer less than or equal to x.


Syntax

Here is the syntax for the floor() method:

import math

math.floor(x)

Note: The floor() function cannot be accessed directly. It needs to be imported from the math module and called via the static object.


Parameters


Return Value


Example

The following examples demonstrate the use of the floor() method:

#!/usr/bin/python
import math   # Import the 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(math.pi) : ", math.floor(math.pi))

The output of the above examples is:

math.floor(-45.17) :  -46
math.floor(100.12) :  100
math.floor(100.72) :  100
math.floor(math.pi) :  3

Python3 Numbers

❮ Python Func Input Ref Set Discard ❯