Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python math.log() Method

Python math.log() Method

Python math Module Python math Module

Python math.log(x) With one argument, the method returns the natural logarithm of x (base e).

Syntax

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

math.log(x[, base])

Parameter Description:

Return Value

Returns a floating-point number float representing the natural logarithm of a number.

Example

The following example returns the natural logarithm of a number:

Example

Import the math package

import

math

Output 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 math Module