def is_power_of_2 ( num ) : log = math . log2 ( num ) return int ( log ) == float ( log )
how to check if number is power of 2 python
Return whether num is a power of two
def is_power_of_2(num):
    """Return whether `num` is a power of two"""
    log = math.log2(num)
    return int(log) == float(log)