Python 3 - Méthode Number log10 ()

La description

le log10() La méthode renvoie le logarithme en base 10 de x pour x> 0.

Syntaxe

Voici la syntaxe pour log10() méthode -

import math

math.log10( x )

Note - Cette fonction n'est pas accessible directement, nous devons donc importer le module mathématique, puis nous devons appeler cette fonction en utilisant l'objet statique mathématique.

Paramètres

x - Ceci est une expression numérique.

Valeur de retour

Cette méthode renvoie le logarithme en base 10 de x pour x> 0.

Exemple

L'exemple suivant montre l'utilisation du log10() méthode.

#!/usr/bin/python3
import math   # This will import math module

print ("math.log10(100.12) : ", math.log10(100.12))
print ("math.log10(100.72) : ", math.log10(100.72))
print ("math.log10(119) : ", math.log10(119))
print ("math.log10(math.pi) : ", math.log10(math.pi))

Production

Lorsque nous exécutons le programme ci-dessus, il produit le résultat suivant -

math.log10(100.12) :  2.0005208409361854
math.log10(100.72) :  2.003115717099806
math.log10(119) :  2.0755469613925306
math.log10(math.pi) :  0.49714987269413385