牌語備忘録 -pygo

あくまでもメモです。なるべくオフィシャルの情報を参照してください。

牌語備忘録 -pygo

Python で XOR のメモ

(Python2.7)

In [1]: 0 ^ 0
Out[1]: 0

In [2]: 0 ^ 1
Out[2]: 1

In [3]: 1 ^ 0
Out[3]: 1

In [4]: 1 ^ 1
Out[4]: 0
In [5]: bool(0) != bool(0)
Out[5]: False

In [6]: bool(0) != bool(1)
Out[6]: True

In [7]: bool(1) != bool(0)
Out[7]: True

In [8]: bool(1) != bool(1)
Out[8]: False

参考

logic - How do you get the logical xor of two variables in Python? - Stack Overflow