#Mastery11 how to call a fuction.

Calling a fuction its exactly what it sounds like. You are telling the fuction to act on the values you have stablished.  to call a fuction  first you must have a variable that will get the return value of your fuction.

#Mastery11 how to call a fuction.

example:

lets say you crated a fuction called: make_sum.

the fuction would look like this:

def make_sum(x,y):
ans=x+y

   return ans

so in your code you would create a varible, lets say:

the_sum =

then you write the fuction, adding the values that you want it to take.

the_sum = make_sum(2,5)

so: 
make_sum(x,y):

ans=x+y

   return ans
will become:

make_sum(2,5):
ans=2+5

   return ans

and the variable the_sum will receve the return value of:

make_sum(2,5):
ans=2+5

   return ans
wich in this case is 7.

The Fun with numbers code in here shows an example of a program that calls differnt fuctions.

note: is very usefull to create your fuctions in a separate place from the rest of the code.

CC BY 4.0 #Mastery11 how to call a fuction. by Eduardo Merino is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.