Méthode Python math.log10()

Python math 模块Module math de Python

Python math.log10(x)La méthode renvoie le logarithme en base 10 de x.

Syntaxe

La syntaxe de la méthode math.log10() est la suivante :

math.log10(x)

Description des paramètres :

  • x-- Obligatoire. Un nombre. Si x n'est pas un nombre, une TypeError est renvoyée. Si la valeur est 0 ou négative, une ValueError est renvoyée.

Valeur de retour

Renvoie un float, représentant le logarithme en base 10 d'un nombre.

Exemple

L'exemple suivant renvoie le logarithme en base 10 d'un nombre :

Exemple

# Importer le package math
import math

# Affiche le logarithme en base 10 d'un nombre
print(math.log10(2.7183))
print(math.log10(2))
print(math.log10(1))

Résultat de sortie :

0.43429738512450866
0.3010299956639812
0.0

Python math 模块Module math de Python

Autres extensions