math.log()

Returns the natural logarithm of n.

Syntax

math.log(n, base)

base is optional and it’s the logarithmic base to use. Default is e.

Example 1

Use math.log() to return the natural log of 12 (base e):

import math
print(math.log(12))
# Output: 2.4849066497880004

Example 2

Use math.log() to return the natural log of 12 (base 5):

import math
print(math.log(12, 5))
# Output: 1.5439593106327716
Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn Python on Codecademy