Python math.log10() メソッド
Python math.log10(x)メソッドは x の 10 を底とする対数を返します。
構文
math.log10() メソッドの構文は次のとおりです:
math.log10(x)
パラメータの説明:
- x-- 必須、数値。x が数値でない場合は TypeError を返します。値が 0 または負の数の場合は ValueError を返します。
戻り値
整数の浮動小数点数 float を返します。これは、数値の 10 を底とする自然対数を表します。
例
次の例では、数値の 10 を底とする自然対数を返します。
例
# math パッケージをインポート
import math
# 数値の 10 を底とする自然対数を出力
print(math.log10(2.7183))
print(math.log10(2))
print(math.log10(1))
import math
# 数値の 10 を底とする自然対数を出力
print(math.log10(2.7183))
print(math.log10(2))
print(math.log10(1))
出力結果:
0.43429738512450866 0.3010299956639812 0.0その他の拡張
Python math モジュール