YouTip LogoYouTip

Python Exercise Example53

# Python2.x Python Exercise Instance 53 [![Image 3: Python 100 Examples](#) Python 100 Examples](#) **Question:** Learn to use bitwise XOR ^ . **Program Analysis:** 0^0=0; 0^1=1; 1^0=1; 1^1=0 Program source code: ## Instance ```python #!/usr/bin/python # -*- coding: UTF-8 -*- if __name__ == '__main__': a = 0o77 b = a ^ 3 print('The a ^ 3 = %d' % b) b ^= 7 print('The a ^ b = %d' % b) The output of the above instance is: ```text The a ^ 3 = 60 The a ^ b = 59 [![Image 4: Python 100 Examples](
← Python Exercise Example54Python Exercise Example52 β†’