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 mathprint(math.log(12))# Output: 2.4849066497880004
Example 2
Use math.log()
to return the natural log of 12
(base 5
):
import mathprint(math.log(12, 5))# Output: 1.5439593106327716
Contributors
- Anonymous contributors