Home >>Python math Module >Python math.log2() Method

Python math.log2() Method

Python math.log2() Method

Python math.log2() method is used to return the base-2 logarithm of the given input number.

Syntax:
math.log2(x)

Parameter Values

Parameter Description
x Required. Specifies the value to calculate the logarithm for.
Here is an example of Python math.log2() method:

import math
print(math.log2(10))
print(math.log2(2))
print(math.log2(1))

Output:
3.321928094887362
1.0
0.0

No Sidebar ads