+ 1
Why do i need for function "return"?
I do the test about this function but i don't mean what do it do
4 Answers
+ 3
Return I assume you mean.
Return will return whatever you tell it to.
in a function for example, it can return a string or integer then that will go back to wherever the function was called from and stored in a variable or printed. it also exits out a function when its called so it should come at the end of a function.
+ 3
Here is another example
def question(x,y):
return f'the answer is {x*y}'
print(question(2,4))
+ 2
You can call functions anywhere in your code when you do this you pass an argument to the function the function will do somthing with the value and then return somthing back to were you called it.
It's asking a question.. its read by somone and then information is sent back to the same place it was asked.