+ 2
Return fucntion
I still can't understand the Concept of return function..
3 Réponses
+ 8
Functions that return values can be used in expressions, just like in math class. When an expression with a function call is evaluated, the functioncall is effectively replaced temporarily by its returned value. Inside the Python function, the value to be returned is given by the expression in the returnstatement.
+ 5
def add(a,b):
c=a+B
return c
Here I have a function that takes in 2 numbers and adds them together. it returns the result. what I do with it is up to me. I could print it as you said..
print(add(1,3)) and the output would be 4.
or I could just assign it to a variable..
sum=add(4,5)
return is what you get back from your function
+ 3
thanks my friend..