In this tutorial, we’ll learn how to use the ceil() method in Python.
Python number method ceil() returns ceiling value of x – the smallest integer not less than x.
Following is the syntax for ceil() method
1 2 3 4 |
import math math.ceil(x) |
Parameter:
x:This is a numeric expression.
Return Value
This method returns smallest integer not less than x.
Example
1 2 3 4 5 6 7 8 9 10 |
#!/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) |
1 2 3 4 5 6 7 |
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.0 |