Saturday, November 22, 2025
HomeLanguagesPython | math.floor() function

Python | math.floor() function

In Python, math module contains a number of mathematical operations, which can be performed with ease using the module. math.floor() function returns the largest integer not greater than x. If number is already integer, same number is returned.

Syntax: math.floor(x)

Parameter:
x: This is a numeric expression.
Returns:  largest integer not greater than x.
Time Complexity: O(1)
Auxiliary Space: O(1)

Code #1: 

Python3




# Python code to demonstrate the working of floor()
   
# importing "math" for mathematical operations
import math
   
x = 33.7
   
# returning the floor of 33.7
print ("The floor of 33.7 is : ", end ="")
print (math.floor(x))


Output:

The floor of 33.7 is : 33

  Code #2: 

Python3




# Python code to demonstrate the working of floor()
   
# importing "math" for mathematical operations
import math
   
# prints the floor using floor() method
print ("math.floor(-13.1) : ", math.floor(-13.1))
print ("math.floor(101.96) : ", math.floor(101.96))


Output:

math.floor(-13.1) :  -14
math.floor(101.96) :  101
RELATED ARTICLES

Most Popular

Dominic
32407 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6785 POSTS0 COMMENTS
Nicole Veronica
11932 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12000 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6864 POSTS0 COMMENTS
Umr Jansen
6851 POSTS0 COMMENTS