import math math.ceil( x )
註:此函式無法直接存取,所以我們需要匯入 math 模組,然後用數學靜態物件呼叫這個函式。
x -- 這是一個數位表示式。
#!/usr/bin/python3 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(math.pi) : ", math.ceil(math.pi))
math.ceil(-45.17) : -45 math.ceil(100.12) : 101 math.ceil(100.72) : 101 math.ceil(math.pi) : 4