Title
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()