Easy Tutorial
❮ Python Os Fpathconf Python String Reverse ❯

Python3 ceil() Function

Python3 Numbers


Description

The ceil(x) function returns the smallest integer greater than or equal to x.


Syntax

Here is the syntax for the ceil() method:

import math

math.ceil( x )

Note: ceil() cannot be accessed directly; it requires importing the math module and calling this method through a static object.


Parameters


Return Value


Example

The following demonstrates the use of the ceil() method:

#!/usr/bin/python3
import math   # Import the math module

print ("math.ceil(-45.17) : ", math.ceil(-45.17))
print ("math.ceil(100.12) : ", math.ceil(100.12))
print ("math.ceil(100.72) : ", math.ceil(100.72))
print ("math.ceil(math.pi) : ", math.ceil(math.pi))

The output of the above example is:

math.ceil(-45.17) :  -45
math.ceil(100.12) :  101
math.ceil(100.72) :  101
math.ceil(math.pi) :  4

Python3 Numbers

❮ Python Os Fpathconf Python String Reverse ❯