Visualizza le tabelle di verità degli operatori logici
not
print("a", "\t", "not")
a=False; print(a, "\t", not a)
a=True ; print(a, "\t", not a)
and
print("a", "\t", "b", "\t", "and")
a=False; b=False; print(a, "\t", b, "\t", a and b)
a=False; b=True ; print(a, "\t", b, "\t", a and b)
a=True ; b=False; print(a, "\t", b, "\t", a and b)
a=True ; b=True ; print(a, "\t", b, "\t", a and b)
or
print("a", "\t", "b", "\t", "or")
a=False; b=False; print(a, "\t", b, "\t", a or b)
a=False; b=True ; print(a, "\t", b, "\t", a or b)
a=True ; b=False; print(a, "\t", b, "\t", a or b)
a=True ; b=True ; print(a, "\t", b, "\t", a or b)
and – or
print("a", "\t", "b", "\t", "and", "\t", "or")
a=False; b=False; print(a, "\t", b, "\t", a and b, "\t", a or b)
a=False; b=True ; print(a, "\t", b, "\t", a and b, "\t", a or b)
a=True ; b=False; print(a, "\t", b, "\t", a and b, "\t", a or b)
a=True ; b=True ; print(a, "\t", b, "\t", a and b, "\t", a or b)
Con for
print("a", "\t", "b", "\t", "and", "\t", "or")
for a in (False, True):
for b in (False, True):
print(a, "\t", b, "\t", a and b, "\t", a or b)