Python ceil() Function
Description
The ceil() function returns the ceiling integer of a number.
Syntax
The following is the syntax for the ceil() method:
import math math.ceil( x )
Note:ceil() cannot be accessed directly; you need to import the math module and call the method via a static object.
Parameter
x -- a numeric expression.Return Value
The function returns the rounded-up integer of the number.Example
The following shows an example of using the ceil() method:
#!/usr/bin/python import math # This will import 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(119L) : ", math.ceil(119L) print "math.ceil(math.pi) : ", math.ceil(math.pi)
After running the above example, the output result is:
math.ceil(-45.17) : -45.0 math.ceil(100.12) : 101.0 math.ceil(100.72) : 101.0 math.ceil(119L) : 119.0 math.ceil(math.pi) : 4.0other extensions