math.log()

Anonymous contributors
Anonymous contributors
Published May 19, 2021Updated Sep 3, 2021
Contribute to Docs

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

All contributors

Looking to contribute?

Learn Python on Codecademy