Python Exercise Example 53
**Problem:** Learn to use the bitwise XOR ^.
**Program Analysis:** 0^0=0; 0^1=1; 1^0=1; 1^1=0
Program source code:
Example
#!/usr/bin/python
-- coding: UTF-8 --
if
name
==
'main'
:
a
=
0o77
b
=
a ^
3
(
'The a ^ 3 = %d'
% b
)
b ^
=
7
(
'The a ^ b = %d'
% b
)
The output of the above example is:
The a ^ 3 = 60
The a ^ b = 59
Python 100 Examples