VOOZH about

URL: https://www.geeksforgeeks.org/python/python-math-ceil-function/

⇱ math.ceil() function - Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

math.ceil() function - Python

Last Updated : 3 Jun, 2026

math.ceil() function returns the smallest integer greater than or equal to a given number. It always rounds a value upward to the nearest whole number. If the input is already an integer, the same value is returned.

This example shows how math.ceil() rounds a positive decimal number up to the next integer.


Output
34

Syntax

math.ceil(x)

  • Parameters: x - A numeric value (int or float).
  • Returns: smallest integer greater than or equal to x.

Examples

Example 1: This example demonstrates how the function behaves with negative values. It still returns the smallest integer that is not less than the given number.


Output
-13

Explanation: math.ceil(-13.1) returns -13 because it is the smallest integer greater than or equal to -13.1.

Example 2: This example applies math.ceil() to a list of decimal numbers and prints their ceiling values one by one.


Output
[3, 8, 102]

Explanation: math.ceil(n) rounds each value in nums upward 2.3 -> 3, 7.01 -> 8, 101.96 -> 102.

Comment
Article Tags: