what does ^ do in python

Heiko Wundram modelnine at modelnine.org
Tue Mar 25 18:15:36 EDT 2008


Am Dienstag, 25. März 2008 23:02:00 schrieb Dark Wind:
> In most of the languages ^ is used for 'to the power of'. In python we have
> ** for that. But what does ^ do?

^ is the binary exclusive-or (xor) operator.

Possibly it helps to see the following (numbers are in binary) to get the 
drift:

00 ^ 01 = 01
01 ^ 01 = 00
10 ^ 01 = 11
11 ^ 01 = 10

-- 
Heiko Wundram



More information about the Python-list mailing list