What does return do?



I was wondering what does return do?
I understand it returns something as output
But I'm confused as to what that output can be used for / how that output can be captured?

I understand that

x = some_function(args*)

will store the output of some_function(args*), which would make it usable for capturing outputs?
Or does it store the function itself and calls it when the variable "x" is called?

Thank you


Return stores a value in the interface.


yes, you know captured the value returned by your function in x, this can be useful if you need to further manipulation with the result of the function.

the return keyword will also end a function, quit important to understand

functions can also call other functions which can return values, for example you will build a cube function which give the cube (^3) of a number, and a divislbe_by_three function, which will return the cube() of number if divisible by 3.


What is "the interface"?


When I say interface, I generally refer to the whole program.


both interface and whole program are not correct terms here.

There are two things you can do with a return value: printing by adding a print keyword before the function call or storing the returned result in a variable


The second thing is what I met. I am sorry for not using the correct terms.


function returns None by default, so in the first method you capture None in x

Hope it all makes sense now

we use the return keyword to overwrite the default


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