How python calls the object of the last function in another function.

def getArrayMean (data_array):

mean_list = []
for i in range(data_array.shape [1]):
    row_mean = np.mean(data_array[:,i:i+1])
    mean_list.append(row_mean)
return mean_list

def drawScatter (setosa, versicolour,para_list):

plt.scatter(setosa, versicolour,edgecolors="white")
plt.scatter(float(para_list[0]),float(para_list[1]),c="r",marker="X")
plt.xlabel("Setosa")
plt.ylabel("Versicolour")
plt.title("Setosa & Versicolour Of Iris")
plt.show()
drawScatter(data_array[:,0:1],data_array[:,1:2],getArrayMean().mean_list)


how does the latter function use the mean_list? in the last function?

Mar.13,2021

calls the target function, passes in parameters, and then receives its return value.

def getArrayMean(data_array):
    ...
    return mean_list
    
def drawScatter(setosa, versicolour,para_list):
    ...
    -sharp data_array
    -sharp 
    mean_list = getArrayMean(data_array)
    drawScatter(data_array[:,0:1], data_array[:,1:2], mean_list)
    -sharp 
    drawScatter(data_array[:,0:1], data_array[:,1:2], getArrayMean(data_array))
Menu