Python log10() 関数

Python 数値


説明

log10() メソッドは、10を底とする x の対数を返します。


構文

以下は log10() メソッドの構文です:

import math

math.log10( x )

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


パラメータ

  • x -- 数値式。

戻り値

x > 0 のとき、10を底とする x の対数を返します。

例

以下は log10() メソッドを使用した例です:

#!/usr/bin/python
import math   # 导入 math 模块

print "math.log10(100.12) : ", math.log10(100.12)
print "math.log10(100.72) : ", math.log10(100.72)
print "math.log10(119L) : ", math.log10(119L)
print "math.log10(math.pi) : ", math.log10(math.pi)

上記の例を実行すると、出力結果は次のようになります:

math.log10(100.12) :  2.00052084094
math.log10(100.72) :  2.0031157171
math.log10(119L) :  2.07554696139
math.log10(math.pi) :  0.497149872694

Python 数値

その他の拡張