I am having trouble understanding, why I get different values in the following two cases:
-Case 1:
def myfunc(a,b,c):
xx = a+b
yy = b+c
return xx, yy
q,w = myfunc(1,2,3)
print(q,w)
Output 1: 3 5
-Case 2:
import numpy as np
q=w=np.zeros(3)
def myfunc(a,b,c):
xx = a+b
yy = b+c
return xx, yy
for i in range(3):
q[i],w[i] = myfunc(1,2,3)
print(q,w)
Output 2: [5. 5. 5.] [5. 5. 5.]
In the second case, both arrays have their entries equal to 5. Could someone explain, why?