Home >>Python math Module >Python math.ceil() Method
Python math.ceil() Method in python is used to return the smallest integral value which is greater than the number nearest integer and it accepts a number/numeric expression.
Syntax:math.ceil(x)
Parameter | Description |
---|---|
x | It is required you want to round upwards the number. If value is not a number, a TypeError occurs. |
import math
print(math.ceil(0.9))
print(math.ceil(2.7))
print(math.ceil(-1.5))
print(math.ceil(13.7))
import math
p1 = 3.18
p2 = 3.43
p3 = 3
p4 = -3.62
p5 = 0
print("ceil(p1): ", math.ceil(p1))
print("ceil(p2): ", math.ceil(p2))
print("ceil(p3): ", math.ceil(p3))
print("ceil(p4): ", math.ceil(p4))
print("ceil(p5): ", math.ceil(p5))