Consider the following code:
def distancias(altitudes,lado,p1,p2):
p1=(r1,c1)
p2=(r2,c2)
a1=altitudes[p1]
a2=altitudes[p2]
d=math.sqrt((lado(r1-r2)**2)+(lado(c1-c2)**2)+(a1-a2)**2)
return d
Altitudes is a matrix and p1
and p2
are elements of the matrix.
When I call the function distancias(teste, 20, (2, 0), (3, 1))
, it is giving me this error:
Traceback (most recent call last):
File "<ipython-input-11-6c6a4bb1ff77>", line 1, in <module>
distancias(teste, 20, (2, 0), (3, 1))
File "C...", line 5, in distancias
p1=(r1,c1)
NameError: name 'r1' is not defined
"Name Error: name is not defined".
(I want to understand it better as i am new to Python)