T
T
Timebird2016-02-29 12:20:02
Python
Timebird, 2016-02-29 12:20:02

How to call a function based on two functions?

There are several functions. The first one forms the first array, the second one forms the second array. In the third, these arrays are multiplied, a new third array is obtained. And as soon as, in the fourth function, I want to plot the dependence of the first array on the third, problems begin.
The code is schematically like this:

def getarray1():
    #Получаю первый массив
    return array1
 
def getarray2():
    #Получаю второй массив
    return array2
 
def getarray3(array1, array2):
    #Перемножаю элементы первого и второго массивов, 
        #получаю третий массив.
    return array3
 
def buildgraph(array1, array3):
    plt.plot(array1, array3)
 
    plt.xlabel('x')
    plt.ylabel('y')
    plt.title('Title name')
    plt.savefig("test.png")
    plt.show()
 
getarray3(getarray1(), getarray2())
buildgraph(getarray1(), getarray3())


As a result, getarray1 is called twice, and then an error is thrown out that getarray3 requires array1 and array2 parameters. Generally speaking: what is wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LeEnot, 2016-02-29
@Timebird

You do not understand the elementary principles of procedural programming.
I would advise you to read this fundamental thing: SICP , fortunately, the publication is already available in Russian.
If desired, the PDF version is easily googled.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question