Python includes exercises 52
Topic: Learn to use the bitwise or |.
Program analysis: 0 | 0 = 0; 0 | 1 = 1; 1 | 0 = 1; 1 | 1 = 1
Source Code:
#!/usr/bin/python # -*- coding: UTF-8 -*- if __name__ == '__main__': a = 077 b = a | 3 print 'a | b is %d' % b b |= 7 print 'a | b is %d' % b
The above example output is:
a | b is 63 a | b is 63