Home >>Python math Module >Python math.log() Method

Python math.log() Method

Python math.log() Method

Python math.log() method is used to return the natural logarithm of the given input number or the logarithm of number to the base.

Syntax:
math.log(x, base)

Parameter Values

Parameter Description
x This is a required parameter. It defines the value to calculate the logarithm for.
base This is an optional parameter. It defines the logarithmic base to use.
Here is an example of Python math.log() method:

import math
print(math.log(10))
print(math.log(2))
print(math.log(1))

Output:
2.302585092994046
0.6931471805599453
0.0
Example 2:

import math
print(math.log(10,10))
print(math.log(2,10))
print(math.log(1,10))

Output:
1.0
0.30102999566398114
0.0