Python3-number-floor
提供:Dev Guides
Python 3-Number floor()メソッド
説明
- floor()*メソッドは、xのフロアを返します。 x以下の最大整数。
構文
以下は* floor()*メソッドの構文です-
import math
math.floor( x )
注-この関数は直接アクセスできないため、数学モジュールをインポートしてから、数学静的オブジェクトを使用してこの関数を呼び出す必要があります。
パラメーター
*x* -これは数値式です。
戻り値
このメソッドは、x以下の最大の整数を返します。
例
次の例は、floor()メソッドの使用法を示しています。
#!/usr/bin/python3
import math # This will import math module
print ("math.floor(-45.17) : ", math.floor(-45.17))
print ("math.floor(100.12) : ", math.floor(100.12))
print ("math.floor(100.72) : ", math.floor(100.72))
print ("math.floor(math.pi) : ", math.floor(math.pi))
出力
上記のプログラムを実行すると、次の結果が生成されます-
math.floor(-45.17) : -46
math.floor(100.12) : 100
math.floor(100.72) : 100
math.floor(math.pi) : 3