CKTIS / Python
math.log
Calcula o expoente a que elevar a base para obter x.
Versão: Python 3.14; repository image, production runtime not attested
Sintaxe
math.log(x[, base])Calcula o expoente a que elevar a base para obter x.
De 3⁴ = 81 resulta 4 e de e⁰ = 1 resulta 0. A base predefinida é e.
Um x ou uma base não positivos geram ValueError e a base 1 gera ZeroDivisionError.
import math
assert math.log(81, 3) == 4.0 and math.log(1) == 0.0
assert math.log(0.25, 0.5) == 2.0
Exemplos
import math
print(math.log(81, 3))
print(math.log(1))
Resultado
4.0 0.0
Um x ou uma base não positivos geram ValueError e a base 1 gera ZeroDivisionError.