Easy Tutorial
❮ Python Comprehensions Python String Islower ❯

Python math.log() Method

Python math Module

The math.log(x) method in Python takes one argument and returns the natural logarithm of x (base e).

Syntax

The syntax for the math.log() method is as follows:

math.log(x[, base])

Parameter Description:

Return Value

Returns a float representing the natural logarithm of a number.

Example

The following example returns the natural logarithm of a number:

Example

# Import math package
import math

# Print the natural logarithm of a number
print(math.log(2.7183))
print(math.log(2))
print(math.log(1))

Output result:

1.0000066849139877
0.6931471805599453
0.0

Python math Module

❮ Python Comprehensions Python String Islower ❯