Python Math.log2() Metoda
Przykład
Znajdź logarytm o podstawie 2 różnych liczb
# Import math Library
import math
# Return the base-2 logarithm
of different numbers
print(math.log2(2.7183))
print(math.log2(2))
print(math.log2(1))
Definicja i użycie
Metoda math.log2()
zwraca logarytm o podstawie 2 liczby.
Składnia
math.log2(x)
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 |
Szczegóły techniczne
Wartość zwrotu: | Wartość float reprezentująca logarytm o podstawie 2 liczby |
---|---|
Wersja Pythona: | 3,3 |