math.ceil()

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 1

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

import math
print(math.ceil(134.2))
# Output: 135

Example 2

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

import math
print(math.ceil(412.959))
# Output: 413

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn Python on Codecademy

Contributors