Python math.log() Method
Example
Find the natural logarithm of different numbers
    # Import math Library
import math 
# Return the natural logarithm 
    of different numbers
print(math.log(2.7183))
print(math.log(2))
    print(math.log(1))
  Try it Yourself »
Definition and Usage
The math.log() method returns the natural logarithm of a number, or the logarithm of number to base.
Syntax
math.log(x, base)
Parameter Values
| Parameter | Description | 
|---|---|
| x | Required. Specifies the value to calculate the logarithm for. If the value is 0 or a negative number, it returns a ValueError. If the value is not a number, it returns a TypeError | 
| base | Optional. The logarithmic base to use. Default is 'e' | 
Technical Details
| Return Value: | A float value, representing the natural logarithm of a number, or the logarithm of number to base | 
|---|---|
| Python Version: | Changed in version 2.3 | 
| Change Log: | The base parameter was added | 
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.