import random


def odds(poweroftwo):
    """ Return True with odds 2**-poweroftwo , else False
        For example, odds(2) will be True roughly 1/4 of the time,
        odds(3) will be True about 1/8 of the time, and so on.
    """
    #
    # To test this look at for example this count of the errors
    #   >> (a,b) = (3,256)
    # len(list(filter(lambda x:x, [odds(a) for i in range(b)])))
    # which should give about b/2**a = 32.
    #
    # The implementation here uses python's getrandbits(n).
    # For example, for n=2, that returns 11, 10, 01, or 00.
    # 00 = 0 will happen with probability 1/4 = 1/2**2 
    #
    return random.getrandbits(poweroftwo) == 0