Return Function vs Print Function in Python

python
functions

#1

What is the difference between Print and Return function?

I understand print function gives the output of whatever we put in the statement. But I am not able to understand the difference in working of these functions.

Regards
Indu


#2

@indutaneja11

Return function is used to terminate / come out of a function. Return can also pass on values to the place where it was called.

Print on the other hand, just sends output. It would be used to either provide some information to the end user or to check values of various parameters in between the run statement.

Example:

print 1+2

would directly print 3

On the other hand, return can be used inside a function as below:

define sum_numbers(a, b):
     return(a+b)

c = sum_numbers(1, 2)
print c

Hope this helps
Kunal


#3

Thanks Kunal. :slight_smile:
This is helpful.