What is return in python plz tell me in simple and easy words with an easy example | Sololearn: Learn to code for FREE!
0

What is return in python plz tell me in simple and easy words with an easy example

25th Jul 2017, 12:46 PM
Asad Ullah Hashmi
Asad Ullah Hashmi - avatar
2 Answers
+ 1
Simple and easy words. It returns a value to whatever called the function. Example: You asked me a question and I returned an answer to you. Now you can use that answer.
25th Jul 2017, 1:23 PM
AgentSmith
0
If you want to print a number for example, you can put the number into the parantheses OR you could put a variable into them. If you have a function which calculates the sum of two numbers, you may want to print it. Return returns a value which could be used instead of a variable: def func (x, y): return x + y print (func (5, 3)) #8
25th Jul 2017, 12:54 PM
Jonas Schröter
Jonas Schröter - avatar