Python math.log() Metodo
Esempio
Trova il logaritmo naturale di numeri diversi
# 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))
Definizione e utilizzo
Il math.log()
metodo restituisce il logaritmo naturale di un numero o il logaritmo di un numero in base.
Sintassi
math.log(x, base)
Valori dei parametri
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' |
Dettagli tecnici
Valore di ritorno: | Un float valore, che rappresenta il logaritmo naturale di un numero o il logaritmo del numero in base |
---|---|
Versione Python: | Modificato nella versione 2.3 |
Registro modifiche: | Il parametro di base è stato aggiunto |