math.ceil()

Published May 19, 2021Updated Aug 17, 2023
Contribute to Docs

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

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))
# Output: 135

Codebyte Example

The following example is runnable and uses the math.ceil() function to return the ceiling of a number:

Code
Output
Loading...

All contributors

Looking to contribute?

Learn Python on Codecademy