Python3 Fonction log()
Description
La méthode log() renvoie le logarithme naturel de x, où x > 0.
Syntaxe
Voici la syntaxe de la méthode log() :
import math math.log( x )
Remarque :log() n'est pas directement accessible ; vous devez importer le module math et appeler la méthode via un objet statique.
Parameters
- x -- Une expression numérique.
Valeur de retour
Renvoie le logarithme naturel de x, où x > 0.Exemple
L'exemple suivant montre l'utilisation de la méthode log() :
#!/usr/bin/python3
import math # 导入 math 模块
print ("math.log(100.12) : ", math.log(100.12))
print ("math.log(100.72) : ", math.log(100.72))
print ("math.log(math.pi) : ", math.log(math.pi))
La sortie de l'exemple ci-dessus est :
math.log(100.12) : 4.6063694665635735 math.log(100.72) : 4.612344389736092 math.log(math.pi) : 1.1447298858494002Autres extensions
Nombres en Python3