pythonmath.ceil什么意思
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培訓機構:千鋒教育。

相關推薦HOT
更多>>
pythonfor循環是什么
pythonfor循環是什么在做遍歷的時候,對于一些數據的反復循環執行,我們會用到for循環的語句。可以說這是新手入門必學的語句之一,在很多基礎循...詳情>>
2023-11-13 07:46:36
pythoncontextmanager()的轉換
python中contextmanager()的轉換1、說明當發出請求時,requests庫會在將請求實際發送到目標服務器之前準備該請求。請求準備包括像驗證頭信息和...詳情>>
2023-11-13 06:34:35
python使用items()遍歷鍵值對
python使用items()遍歷鍵值對字典可以用來存儲各種方式的信息,所以有很多方式可以通過字典的所有鍵值對、鍵或值。說明1、即使通過字典,鍵值對...詳情>>
2023-11-13 04:24:15
python實例方法中self的作用
python實例方法中self的作用說明1、無論是創建類的構造方法還是實例方法,最少要包含一個參數self。2、通過實例的self參數與對象進行綁定,程序...詳情>>
2023-11-13 03:46:48