Python數字log10()
方法返回x
(x > 0
)基數為10
的對數。
語法
以下是log10()
方法的語法 -
import math
math.log10( x )
注意 - 此方法不能直接訪問,需要導入
math
模組,然後使用math
靜態對象調用此函數。
參數
- x - 這是一個數字運算式。
返回值
- 該方法返回
x
基數為10
的自然對數(x > 0
)。
示例
以下示例顯示了log10()
方法的用法。
#!/usr/bin/python3
import math # This will import math module
print ("math.log10(100.12) : ", math.log10(100.12))
print ("math.log10(100.72) : ", math.log10(100.72))
print ("math.log10(119) : ", math.log10(119))
print ("math.log10(math.pi) : ", math.log10(math.pi))
當運行上述程式時,它會產生以下結果 -
math.log10(100.12) : 2.0005208409361854
math.log10(100.72) : 2.003115717099806
math.log10(119) : 2.0755469613925306
math.log10(math.pi) : 0.49714987269413385