I want to know about the significance of return function - i am a beginner


#1

while defining a function why do we write 'return True' after we have given the print command.

def bigger(first, second):
print max(first, second)
return True


#2

From my limited understanding:
print = something you want to show to the user of the program
return = returning the results to other functions and parts of your program so they can do something with them


#3

What does a lawn mower do? It serves a function, but it doesn't give anything back. In programming terms it is still a function because it can be called upon more than once to perform the same thing.

What does an automated teller do? It serves a function as well. But we have to give it something to work with (parameter) namely, our bank card, and if allowed it gives us back cash, as in it returns cash.


#4

Technically we should refer to return as a command, rather than as a function.

Interestingly, print is also a command in Python 2, but is a function in Python 3.

Here, at Codecademy, we are still using Python 2, but that may soon change.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.