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 ansso 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 answill become:
make_sum(2,5):
ans=2+5
return ansand the variable the_sum will receve the return value of:
make_sum(2,5):
ans=2+5
return answich 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.
No hay comentarios:
Publicar un comentario