print('Somme logique')
print(0 | 0)
print(0 | 1)
print(1 | 0)
print(1 | 1)
print('ET logique')
print(0 & 0)
print(0 & 1)
print(1 & 0)
print(1 & 1)
print('Somme logique exclusive')
print(0 ^ 0)
print(0 ^ 1)
print(1 ^ 0)
print(1 ^ 1)
print('Inverser')
print(bin(0))
print(bin(~0))
print(bin(1))
print(bin(~1))
print('décalage')
print(bin(1 << 0))
print(bin(1 << 1))
print(bin(1 << 2))
print(bin(1 << 3))
Résultat de l'exécution:
Somme logique
0
1
1
1
ET logique
0
0
0
1
Somme logique exclusive
0
1
1
0
Inverser
0b0
-0b1
0b1
-0b10
décalage
0b1
0b10
0b100
0b1000
Recommended Posts