Python3 log10()函式

2019-10-16 23:11:57
log10() 方法返回基數為10的x對數(x>0)。

語法

以下是log10()方法的語法:
import math

math.log10( x )

註:此函式無法直接存取,所以我們需要匯入 math 模組,然後用數學靜態物件呼叫這個函式。

引數

  • x -- 這是一個數位表示式。

返回值

這個方法返回基數為10的x對數(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