Projet 2
- lilian0305060
- 6 oct. 2022
- 1 min de lecture
Corrigez ce programme ci-dessous pour avoir l'addition des nombres binaires
01010001
00110011
n = []
p = []
r = []
c = False
for i in range():
a = n[i]
b = p[i]
unite = (a and not(b) and not(c)) or\
(not(a) and b and not(c)) or\
(not(a) and not(b) and c) or\
(a and b and c)
r = [int(unite)] + r
c = (a and b) or (b and c) or (a and c)
r = +r
print(r)
a = "01010001"
b = "00110011"
sum = bin(int(a, 2) + int(b, 2))
print(sum[2:])
print (sum)
Posts récents
Voir toutExercice 1: Réponse B: E en binaire = 1110 et D en binaire = 1101 Exercice 2: Réponse C: 15 en bianire = 1111 (voir tableau) Exercice 3:...
Testez chacune des instructions suivantes dans le shell d’un éditeur Python et expliquez leurs rôles Écriture d’un entier positif : >>>...
Comentários