What is math.floor() in Python?
The floor() function returns the next largest integer less than or equal to a number. Figure 1 below shows the mathematical representation of the floor() function.
The
mathmodule is required for this function.
Syntax
floor(number)
Parameter
This function requires a number to round down as a parameter.
Return value
The floor() function returns the next largest integer less than or equal to the number set as a parameter.
Example
import math#positive integer sent as parameterprint "floor(10) : ", math.floor(10)#negative integer sent as parameterprint "floor(-10) : ", math.floor(-10)#positive float value sent as parameterprint "floor(2.1) : ", math.floor(2.1)#negative float value sent as parameterprint "floor(-2.1) : ", math.floor(-2.1)