Método Python math.log()
Ejemplo
Encuentra el logaritmo natural de diferentes números.
# Import math Library
import math
# Return the natural logarithm
of different numbers
print(math.log(2.7183))
print(math.log(2))
print(math.log(1))
Definición y uso
El math.log()
método devuelve el logaritmo natural de un número, o el logaritmo del número en base.
Sintaxis
math.log(x, base)
Valores paramétricos
Parameter | Description |
---|---|
x | Required. Specifies the value to calculate the logarithm for. If the value is 0 or a negative number, it returns a ValueError. If the value is not a number, it returns a TypeError |
base | Optional. The logarithmic base to use. Default is 'e' |
Detalles técnicos
Valor devuelto: | Un float valor, que representa el logaritmo natural de un número, o el logaritmo de un número en base |
---|---|
Versión de Python: | Cambiado en la versión 2.3 |
Registro de cambios: | Se agregó el parámetro base . |