Python3 log10() Function
Description
The log10() method returns the base-10 logarithm of x, where x>0.
Syntax
The syntax of the log10() method is as follows:
import math
math.log10( x )
**Note:** log10() cannot be accessed directly; you need to import the math module and call the method through the static object.
Parameters
- x -- a numeric expression.
Return Value
Returns the base-10 logarithm of x, where x>0.
Example
The following shows examples of using the log10() method:
#!/usr/bin/python3
import math # 导入 math 模块
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))
Running the example above produces:
math.log10(100.12) : 2.0005208409361854
math.log10(100.72) : 2.003115717099806
math.log10(119) : 2.075546961392531
math.log10(math.pi) : 0.4971498726941338
Python3 Numbers