Python Tutorial Python Advanced Python References Python Libraries

Python math - floor() Function



The Python math.floor() function returns the next lowest integer value by rounding down the specified number, if necessary. In other words, it rounds the fraction DOWN of the given number.

Syntax

math.floor(x) 

Parameters

x Required. Specify a number.

Return Value

Returns the next lowest integer value by rounding DOWN the specified number, if necessary.

Example:

In the example below, floor() function is used to round the fraction DOWN of the specified number.

import math

print(math.floor(10.5))
print(math.floor(-10.5))
print(math.floor(0.5))
print(math.floor(-0.5))

The output of the above code will be:

10
-11
0
-1

❮ Python Math Module