Python3 log10() Function

Python3 数字Python3 Numbers


Description

The log10() method returns the base-10 logarithm of x, where x>0.


Syntax

The following is the syntax for the log10() method:

import math

math.log10( x )

Note:log10() is not directly accessible; you need to import the math module and invoke this method via the static object.


Parameters

  • x -- numeric expression.

Return Value

Returns the base-10 logarithm of x, where x>0.

Examples

The following example demonstrates the use of 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))

The output of the above example after execution is:

math.log10(100.12) :  2.0005208409361854
math.log10(100.72) :  2.003115717099806
math.log10(119) :  2.075546961392531
math.log10(math.pi) :  0.4971498726941338

Python3 数字Python3 Numbers

Other Extensions