This article describes how to use the ceil () method in Python. it is a required method for getting started with Python. For more information, see ceil () method returns the maximum value of x-the smallest integer not less than x.
Syntax
The syntax of the ceil () method is as follows:
Import mathmath. ceil (x)
Note: This function cannot be directly accessed. Therefore, we need to import the math module and then use the static object of math to call this function.
Parameters
X -- this is a numeric expression.
Return value
This method returns the smallest integer not less than x.
Example
The following example shows how to use the ceil () method.
#! /Usr/bin/pythonimport math # This will import math moduleprint "math. ceil (-45.17): ", math. ceil (-45.17) print "math. ceil (1, 100.12): ", math. ceil (100.12) print "math. ceil (1, 100.72): ", math. ceil (100.72) print "math. ceil (119L): ", math. ceil (119L) print "math. ceil (math. pi): ", math. ceil (math. pi)
When we run the above program, it will produce the following results:
Math. ceil (-45.17):-45.0math.ceil (100.12): 101.0math.ceil (100.72): 101.0math.ceil (119L): 119.0math.ceil (math. pi): 4.0