Valeur retournée d'une fonction

dan1ye Messages postés 7 Date d'inscription jeudi 31 juillet 2014 Statut Membre Dernière intervention 6 août 2014 - 5 août 2014 à 16:23
hbouia Messages postés 112 Date d'inscription mardi 30 juillet 2013 Statut Membre Dernière intervention 22 novembre 2022 - 2 nov. 2014 à 21:22
Bonjour,
j'aimerai savoir comment je peux m'y prendre pour recuperer la valeur d'une fonction et la stocker dans une variable!
Pouvez vous m'orienter svp


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



j'aimerai executer le SN

M'erci d'avance

1 réponse

hbouia Messages postés 112 Date d'inscription mardi 30 juillet 2013 Statut Membre Dernière intervention 22 novembre 2022 12
2 nov. 2014 à 21:22
A priori:

Cn=nord()
Cs=south()
SN=(int(Cn)-int(Cs))**2

Je ne sais pas si répondrait à votre question !?
0
Rejoignez-nous