Python math.log()メソッド
例
異なる数の自然対数を見つける
# Import math Library
import math
# Return the natural logarithm
of different numbers
print(math.log(2.7183))
print(math.log(2))
print(math.log(1))
定義と使用法
このmath.log()
メソッドは、数値の自然対数、または基数の数値の対数を返します。
構文
math.log(x, base)
パラメータ値
Parameter | Description |
---|---|
x | Required. Specifies the value to calculate the logarithm for. If the value is 0 or a negative number, it returns a ValueError. If the value is not a number, it returns a TypeError |
base | Optional. The logarithmic base to use. Default is 'e' |
技術的な詳細
戻り値: | float 数値の自然対数、または基数となる数値の対数を表す値 |
---|---|
Pythonバージョン: | バージョン2.3で変更 |
変更ログ: | 基本パラメータが追加されました |