def method2():
    truth_table = [[1,1], [1,0], [0,1], [0,0]]
    for a, b in truth_table:
        print(f"and {a} & {b}: {a & b}")
    for a, b in truth_table:
        print(f"nand ~({a} & {b}): {((a & b) + 1) % 2}") # warning: ~ negates entire integer without modulo
    for a, b in truth_table:
        print(f"or {a} | {b}: {a | b}")
    for a, b in truth_table:
        print(f"nor ~({a} | {b}): {((a | b) + 1) % 2}")  # warning: see above
    for a, b in truth_table:
        print(f"xor {a} ^ {b}: {a ^ b}")


# call bitwise evaluation of truth table
if __name__ == "__main__":
    print("***** Method 2 *****")
    method2()
***** Method 2 *****
and 1 & 1: 1
and 1 & 0: 0
and 0 & 1: 0
and 0 & 0: 0
nand ~(1 & 1): 0
nand ~(1 & 0): 1
nand ~(0 & 1): 1
nand ~(0 & 0): 1
or 1 | 1: 1
or 1 | 0: 1
or 0 | 1: 1
or 0 | 0: 0
nor ~(1 | 1): 0
nor ~(1 | 0): 0
nor ~(0 | 1): 0
nor ~(0 | 0): 1
xor 1 ^ 1: 0
xor 1 ^ 0: 1
xor 0 ^ 1: 1
xor 0 ^ 0: 0