Метод Python math.log2()
Пример
Найдите логарифм по основанию 2 различных чисел
# 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))
Определение и использование
Метод math.log2()
возвращает логарифм числа по основанию 2.
Синтаксис
math.log2(x)
Значения параметров
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 |
Технические детали
Возвращаемое значение: | Значение float , представляющее логарифм числа по основанию 2. |
---|---|
Версия Python: | 3.3 |