Получите количество бит на Integer в Python
a = 100
a.bit_length()
# 7
Anxious Alligator
a = 100
a.bit_length()
# 7
counts = bytes(bin(x).count("1") for x in range(256)) # py2: use bytearray