python的ceil()函數返回數字的上入整數。
ceil的語法格式為
importmath
math.ceil(x)
注意:ceil()是不能直接訪問的,需要導入math模塊,通過靜態對象調用該方法。
參數:x--數值表達式;
返回值:函數返回數字的上入整數。
以下展示了使用ceil()方法的實例:
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)
輸出結果
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
以上內容為大家介紹了python培訓之math.ceil什么意思,希望對大家有所幫助,如果想要了解更多Python相關知識,請關注IT培訓機構:千鋒教育。