What does it mean to "call" a function in Python?

user2837438 picture user2837438 · Oct 2, 2013 · Viewed 171.9k times · Source

What does "call" mean and do? How would you "call" a function in Python?

Answer

Joel Green picture Joel Green · Oct 2, 2013

When you "call" a function you are basically just telling the program to execute that function. So if you had a function that added two numbers such as:

def add(a,b):
    return a + b

you would call the function like this:

add(3,5)

which would return 8. You can put any two numbers in the parentheses in this case. You can also call a function like this:

answer = add(4,7)

Which would set the variable answer equal to 11 in this case.