0 votes
1 view
in Python by (20.3k points)

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

2 Answers

0 votes
by (40.4k points)

When we  "call" a function we are generally 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 can also call the function like this:


Which will 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 will set the variable answer equal to 11 in this case.

0 votes
by (107k points)

To "call" means to make a reference in your code to a function that is written elsewhere. This function "call" can be made to the standard Python library (stuff that comes installed with Python), third-party libraries (stuff other people wrote that you want to use), or your own code (stuff you wrote). For example:

#!/usr/env python 

import os 

def foo(): 

return "hello world" 

print os.getlogin() 

print foo()

Related questions

0 votes
1 answer
asked Oct 8, 2019 in Python by Sammy (47.8k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !