top of page
NSI_Première: Sarah Marcerou
Chapitre 2
#n = [True,False,True,False,True,False,True,False,True,False]
#p = [True,False,True,False,True,False,True,False,True,False]
#c = False
n = [1,0,1,0,1,0,1,0,1,0]
p = [1,0,1,0,1,0,1,0,1,0]
r = [0,0,0,0,0,0,0,0,0,0,0]
c = 0
for i in range(9,-1,-1):
a = n[i]
b = p[i]
print (i)
r[i+1] = (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)
c = (a and b) or (b and c) or (a and c)
r[0] = c
print (r)
a = "1010101010"
b = "1010101010"
sum = bin(int(a,2)+int(b,2))
print(sum)
>>>
*** Console de processus distant Réinitialisée ***
9
8
7
6
5
4
3
2
1
0
[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0]
0b10101010100
bottom of page