Learning Scientific Programming with Python (2nd edition)
P2.2.1: The XOR operator
Question P2.2.1
There is no exclusive-or operator provided "out of the box" by Python, but one can be constructed from the existing operators. Find two different ways of doing this. (The XOR truth table is provided below).
P | Q | P xor Q |
---|---|---|
True | True | False |
False | True | True |
True | False | True |
False | False | False |