Método Python math.log()
Exemplo
Encontre o 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))
Definição e uso
O math.log()
método retorna o logaritmo natural de um número ou o logaritmo de número para base.
Sintaxe
math.log(x, base)
Valores de parâmetro
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' |
Detalhes técnicos
Valor de retorno: | Um float valor, representando o logaritmo natural de um número, ou o logaritmo de número para base |
---|---|
Versão do Python: | Alterado na versão 2.3 |
Registro de alterações: | O parâmetro base foi adicionado |