Python3 log10()函数

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

上一篇: Python3循环 下一篇: Python3数字