Easy Tutorial
❮ Python Os Fchmod Ref Math Log10 ❯

Python math.ceil() Method

Python math Module

The math.ceil(x) method in Python rounds x up to the nearest integer.

The math.floor() method rounds a number down to the nearest integer.

Syntax

The syntax for the math.ceil() method is as follows:

math.ceil(x)

Parameter Description:

Return Value

Returns an integer representing the rounded number.

Example

The following example returns the number rounded up to the nearest integer:

Example

# Import math package
import math

# Output the number rounded up to the nearest integer
print(math.ceil(1.4))
print(math.ceil(5.3))
print(math.ceil(-5.3))
print(math.ceil(22.6))
print(math.ceil(10.0))

Output result:

2
6
-5
23
10

Python math Module

❮ Python Os Fchmod Ref Math Log10 ❯