Python3 ceil() function
Description
The ceil(x) function returns the smallest integer greater than or equal to x.
Syntax
Below is the syntax of 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.
Parameters
x -- numeric expression.Return Value
The function returns the smallest integer greater than or equal to x.Examples
The following example demonstrates the use of the ceil() method:
#!/usr/bin/python3
import math # 导入 math 模块
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))
After the above example runs, the output is:
math.ceil(-45.17) : -45 math.ceil(100.12) : 101 math.ceil(100.72) : 101 math.ceil(math.pi) : 4Other Extensions
Python3 Numbers