Latest web development tutorials

Python3 log () function

Python3 digital Python3 digital


description

log () method returns the natural logarithm of x, x> 0.


grammar

The following is the syntax log () method:

import math

math.log( x )

Note: log () is not directly accessible, we need to import math module, invoke the method through static object.


parameter

  • x - numeric expression.

return value

Returns the natural logarithm of x, x> 0.

Examples

The following shows an example of using the log () method:

#!/usr/bin/python3
import math   # 导入 math 模块

print ("math.log(100.12) : ", math.log(100.12))
print ("math.log(100.72) : ", math.log(100.72))
print ("math.log(math.pi) : ", math.log(math.pi))

After running the above example output is:

math.log(100.12) :  4.6063694665635735
math.log(100.72) :  4.612344389736092
math.log(math.pi) :  1.1447298858494002

Python3 digital Python3 digital