Python Exercise Example 52
**Problem:** Learn to use the bitwise OR |.
**Program Analysis:** 0|0=0; 0|1=1; 1|0=1; 1|1=1
Example (Python 2.0+)
#!/usr/bin/python
-- coding: UTF-8 --
if
name
==
'
main
'
:
a
=
0
o77
b
=
a
|
3
(
'
a | b is %d
'
%
b
)
b
|=
7
(
'
a | b is %d
'
%
b
)
The output of the above example is:
a | b is 63
a | b is 63
Python 100 Examples