DeMorgan’s Law
DeMorgan’s law is a simple law that I learned at UPT during one of my hardware classes. While it is useful in hardware it, it is also useful when writing programs. If you have a condition like not (A and B), you can rewrite it to !A or !B. 1 2 3 4 5 6 7 8 9 10 11 12 13 if __name__ == '__main__': a = True b = True if not (a and b): print("True") else: print("False") if not a or not b: print("True") else: print("False")