Python Math.log() Metoda
Przykład
Znajdź logarytm naturalny różnych liczb
# 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))
Definicja i użycie
Metoda math.log()
zwraca logarytm naturalny liczby lub logarytm liczby do podstawy.
Składnia
math.log(x, base)
Wartości parametrów
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' |
Szczegóły techniczne
Wartość zwrotu: | Wartość float reprezentująca logarytm naturalny liczby lub logarytm liczby o podstawie |
---|---|
Wersja Pythona: | Zmieniono w wersji 2.3 |
Dziennik zmian: | Dodano parametr bazowy |