Méthode Python math.log2()
Exemple
Trouver le logarithme en base 2 de différents nombres
# Import math Library
import math
# Return the base-2 logarithm
of different numbers
print(math.log2(2.7183))
print(math.log2(2))
print(math.log2(1))
Définition et utilisation
La math.log2()
méthode renvoie le logarithme en base 2 d'un nombre.
Syntaxe
math.log2(x)
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 |
Détails techniques
Valeur de retour : | Une float valeur, représentant le logarithme en base 2 d'un nombre |
---|---|
Version Python : | 3.3 |