Python math.log()- Methode
Beispiel
Finde den natürlichen Logarithmus verschiedener Zahlen
# 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))
Definition und Verwendung
Die math.log()
Methode gibt den natürlichen Logarithmus einer Zahl oder den Logarithmus von Zahl zur Basis zurück.
Syntax
math.log(x, base)
Parameterwerte
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' |
Technische Details
Rückgabewert: | Ein float Wert, der den natürlichen Logarithmus einer Zahl oder den Logarithmus der Zahl zur Basis darstellt |
---|---|
Python-Version: | Geändert in Version 2.3 |
Änderungsprotokoll: | Der Basisparameter wurde hinzugefügt |