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.

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
Loading...

All contributors

Contribute to Docs

Learn Python on Codecademy