Python-number-ceil
提供:Dev Guides
Python Number ceil()メソッド
説明
Pythonの数値メソッド* ceil()は、上限値 *x -x以上の最小整数を返します。
構文
以下は、* ceil()*メソッドの構文です-
import math
math.ceil( x )
注-この関数は直接アクセスできないため、数学モジュールをインポートしてから、数学静的オブジェクトを使用してこの関数を呼び出す必要があります。
パラメーター
- x -これは数値式です。
戻り値
このメソッドは、x以上の最小の整数を返します。
例
次の例は、ceil()メソッドの使用法を示しています。
#!/usr/bin/python
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(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