Return fucntion | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Return fucntion

I still can't understand the Concept of return function..

28th Apr 2017, 7:07 PM
Rahul Kumawat
Rahul Kumawat - avatar
3 Answers
+ 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.
28th Apr 2017, 7:28 PM
Balkrishna Bhatt
Balkrishna Bhatt - avatar
+ 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
28th Apr 2017, 8:13 PM
LordHill
LordHill - avatar
+ 3
thanks my friend..
28th Apr 2017, 8:16 PM
Rahul Kumawat
Rahul Kumawat - avatar