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