""" Print of Logic tables """ import operator anzahlVariablen = 2 x1 = False x2 = False Ueberschrift = " Index | x2 x1 | and or xor" print(Ueberschrift) print("-" * len(Ueberschrift)) for index in range(2**anzahlVariablen): print( f"{index} |{x2} {x1} | {x2 and x1} {int(x2 or x1)} {int(x2 ^ x1)}" ) x1 = not x1 if (index + 1) % 2 == 0: x2 = not x2