Méthode Python math.log()
Exemple
Trouver le logarithme naturel de différents nombres
# 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))
Définition et utilisation
La math.log()
méthode renvoie le logarithme népérien d'un nombre, ou le logarithme du nombre à la base.
Syntaxe
math.log(x, base)
Valeurs des paramètres
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' |
Détails techniques
Valeur de retour : | Une float valeur, représentant le logarithme népérien d'un nombre, ou le logarithme du nombre en base |
---|---|
Version Python : | Modifié dans la version 2.3 |
Journal des modifications : | Le paramètre de base a été ajouté |