Python3 log() 関数
説明
log() メソッドは x の自然対数を返します。x > 0 です。
構文
以下は log() メソッドの構文です:
import math math.log( x )
注意:log() は直接アクセスできません。math モジュールをインポートし、静的オブジェクトを介してこのメソッドを呼び出す必要があります。
パラメータ
- x -- 数値式。
戻り値
x の自然対数を返します。x > 0 です。例
以下は log() メソッドを使用した例です:
#!/usr/bin/python3
import math # 导入 math 模块
print ("math.log(100.12) : ", math.log(100.12))
print ("math.log(100.72) : ", math.log(100.72))
print ("math.log(math.pi) : ", math.log(math.pi))
上記の例を実行すると、出力結果は次のようになります:
math.log(100.12) : 4.6063694665635735 math.log(100.72) : 4.612344389736092 math.log(math.pi) : 1.1447298858494002その他の拡張