Python log10() Function
Description
The log10() method returns the logarithm of x to base 10.
Syntax
The following is the syntax of the log10() method:
import math math.log10( x )
Note:log10() is not directly accessible; you need to import the math module and call this method via a static object.
Parameters
- x -- A numeric expression.
Return Value
Returns the logarithm of x to base 10, where x > 0.Example
The following example demonstrates the use of the log10() method:
#!/usr/bin/python import math # 导入 math 模块 print "math.log10(100.12) : ", math.log10(100.12) print "math.log10(100.72) : ", math.log10(100.72) print "math.log10(119L) : ", math.log10(119L) print "math.log10(math.pi) : ", math.log10(math.pi)
After running the above example, the output result is:
math.log10(100.12) : 2.00052084094 math.log10(100.72) : 2.0031157171 math.log10(119L) : 2.07554696139 math.log10(math.pi) : 0.497149872694Other Extensions
Python Numbers