Python Funktion log ()
Beschreibung
log () Methode gibt den natürlichen Logarithmus von x.
Grammatik
Im Folgenden ist die Syntax log () Methode:
import math math.log( x )
Hinweis: log () nicht direkt zugänglich ist , müssen wir Mathematikmodul zu importieren, rufen Sie die Methode durch statisches Objekt.
Parameter
- x - numerischer Ausdruck.
Rückgabewert
Gibt den natürlichen Logarithmus von x, x> 0.Beispiele
Nachfolgend ein Beispiel für die Verwendung der log () Methode:
#!/usr/bin/python import math # This will import math module print "math.log(100.12) : ", math.log(100.12) print "math.log(100.72) : ", math.log(100.72) print "math.log(119L) : ", math.log(119L) print "math.log(math.pi) : ", math.log(math.pi)
Nach dem obigen Beispiel Ausgang läuft:
math.log(100.12) : 4.60636946656 math.log(100.72) : 4.61234438974 math.log(119L) : 4.77912349311 math.log(math.pi) : 1.14472988585