Je comprends pas python :-s
jonyx3
Messages postés
2
Date d'inscription
Statut
Membre
Dernière intervention
-
jonyx3 Messages postés 2 Date d'inscription Statut Membre Dernière intervention -
jonyx3 Messages postés 2 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Bonjour, voila j'ai ce gentil petit programme... je dois trouver le code a la fin, mais pourriez vous m'expliquer chaque étape? parce qu'a l'exam je pourrai pas avoir de pc... merci
>>>def func(x):
a=0
for i in x:
a=a+1
return a
>>>def func2(x):
s=0
it=0
a=func(x)
r=0
while it<a-1:
s=s+x[it]
it=it+1
if(s%2==0) and (x[a-1]==1):
r=1
elif(s%2==1) and (x[a-1]==0):
r=1
else:
r=0
return r
>>>list=[]
>>>list2=[]
>>>list.append((1,0))
>>>list.append((1,1,0))
>>>list.append((1,0,0,1,1))
>>>list.append((1,0,0,0,1))
>>>list.append((0,0,1))
>>>list.append((0,0,1,0))
>>>for x in list:
list2.append(func2(x))
>>>list2
Bonjour, voila j'ai ce gentil petit programme... je dois trouver le code a la fin, mais pourriez vous m'expliquer chaque étape? parce qu'a l'exam je pourrai pas avoir de pc... merci
>>>def func(x):
a=0
for i in x:
a=a+1
return a
>>>def func2(x):
s=0
it=0
a=func(x)
r=0
while it<a-1:
s=s+x[it]
it=it+1
if(s%2==0) and (x[a-1]==1):
r=1
elif(s%2==1) and (x[a-1]==0):
r=1
else:
r=0
return r
>>>list=[]
>>>list2=[]
>>>list.append((1,0))
>>>list.append((1,1,0))
>>>list.append((1,0,0,1,1))
>>>list.append((1,0,0,0,1))
>>>list.append((0,0,1))
>>>list.append((0,0,1,0))
>>>for x in list:
list2.append(func2(x))
>>>list2
A voir également:
- Je comprends pas python :-s
- Citizen code python avis - Accueil - Outils
- Mot secret python pix ✓ - Forum Python
- Python est introuvable. exúcutez sans argument pour procúder ó l ✓ - Forum Python
- Python par la pratique : 101 exercices corrigés pdf - Forum Python
- Exercice python - Forum Python