print('Logical sum')
print(0 | 0)
print(0 | 1)
print(1 | 0)
print(1 | 1)
print('Logical AND')
print(0 & 0)
print(0 & 1)
print(1 & 0)
print(1 & 1)
print('Exclusive OR')
print(0 ^ 0)
print(0 ^ 1)
print(1 ^ 0)
print(1 ^ 1)
print('Invert')
print(bin(0))
print(bin(~0))
print(bin(1))
print(bin(~1))
print('shift')
print(bin(1 << 0))
print(bin(1 << 1))
print(bin(1 << 2))
print(bin(1 << 3))
Execution result:
Logical sum
0
1
1
1
Logical AND
0
0
0
1
Exclusive OR
0
1
1
0
Invert
0b0
-0b1
0b1
-0b10
shift
0b1
0b10
0b100
0b1000
Recommended Posts