Thursday, November 20, 2025
HomeLanguagesPython | math.ceil() function

Python | math.ceil() function

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

Syntax: math.ceil(x)

Parameter:
x: This is a numeric expression.

Returns:  Smallest integer not less than x.
Time Complexity: O(1)
Auxiliary Space: O(1)

Code #1: 

Python3




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


Output:

The ceil of 33.7 is : 34

  Code #2: 

Python3




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


Output:

math.ceil(-13.1) :  -13
math.ceil(101.96) :  102
RELATED ARTICLES

Most Popular

Dominic
32405 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6778 POSTS0 COMMENTS
Nicole Veronica
11927 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11995 POSTS0 COMMENTS
Shaida Kate Naidoo
6905 POSTS0 COMMENTS
Ted Musemwa
7163 POSTS0 COMMENTS
Thapelo Manthata
6861 POSTS0 COMMENTS
Umr Jansen
6846 POSTS0 COMMENTS