Latest web development tutorials

Pythonのはceil()関数

Pythonの数値 Pythonの数値


説明

()関数は、CEILに整数を返します。


文法

次の構文はceil()メソッドです。

import math

math.ceil( x )

注:CEIL()は直接アクセスできません、あなたは数学のモジュールをインポートする必要があり、静的オブジェクトを介してメソッドを呼び出します。


パラメータ

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

Pythonの数値 Pythonの数値