Bonjour,
J'aimerai savoir comment je peux recuperer la valeur retournée d'une fonction, la stocker dans une variable afin de l'exploiter.
Voici le code de la fonction et je veux recuperer Cn et Cs pour un calcul
Pouvez vous me depanner svp?
Comment faire svpCode:Matrix = [[0 for x in xrange(10)] for x in xrange(10)] x=4 #Coordonnee en x egal ind_ic y=4 #Coordonnee en y egal a p et ind_jc r=2 #rayon de couverture SN=0 #Difference entre Nord et Sud def maj(): Matrix[4][2]=1 #West" Matrix[4][4]=5 #Centre de matrice noeud" Matrix[4][6]=3 #East" Matrix[2][4]=2 #"Nord Matrix[6][4]=4 #"South def show(): for line in Matrix: print line return line def nord(): global x global y global r Cn=0 i=0 i=y-r for somme in range(len(Matrix)): if i <= (y+r): Cn+=Matrix[2][i] i+=1 return Cn def south(): global x global y global r Cs=0 i=0 i=y-r for somme in range(len(Matrix)): if i <= (y+r): Cs+=Matrix[6][i] i+=1 return Cs maj() show() nord() south() SN=(int(Cn)-int(Cs))**2
Merci,
-----


 
 
 , j'avais dû me tromper quelque part.
, j'avais dû me tromper quelque part. Envoyé par daniye
 Envoyé par daniye 
 ....fais attention à tes index.
 ....fais attention à tes index.
						