Python3 Función log()

Python3 数字Números en Python3


Descripción

El método log() devuelve el logaritmo natural de x, x > 0.


Sintaxis

La sintaxis del método log() es la siguiente:

import math

math.log( x )

Nota:No se puede acceder a log() directamente; es necesario importar el módulo math y llamar a este método mediante un objeto estático.


Parámetros

  • x -- expresión numérica.

Valor de retorno

Devuelve el logaritmo natural de x, x>0.

Ejemplo

El siguiente ejemplo muestra el uso del método 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))

El resultado de ejecutar el ejemplo anterior es:

math.log(100.12) :  4.6063694665635735
math.log(100.72) :  4.612344389736092
math.log(math.pi) :  1.1447298858494002

Python3 数字Números en Python3

Otras extensiones