Python math.ceil()

karthikMurali1651016565's avatar
Published May 19, 2021Updated Mar 17, 2024
Contribute to Docs

Takes in a numeric data type and rounds the value up to the nearest integer.

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.
    • With Certificate
    • Beginner Friendly.
      24 hours

Syntax

math.ceil(n)

The math.ceil() function takes in a value and returns its ceiling, the smallest integer greater than or equal to that value.

Example

Use math.ceil() to return the ceiling of 134.2:

import math
print(math.ceil(134.2))

The above code gives the following output:

135

Codebyte Example

Run the following example that uses the math.ceil() function to understand its working:

Code
Output

All contributors

Contribute to Docs

Learn Python on Codecademy

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.
    • With Certificate
    • Beginner Friendly.
      24 hours