0

What does return actually do?

I don't understand what return does. A few days ago I read a book about Python but I didn't understand some programs because of return. Please help me :D I hope you understand my question.

17th Sep 2016, 9:16 PM
Moritz Fotografie
Moritz Fotografie - avatar
2 odpowiedzi
+ 2
Return in a function returns to where the function was called in the execution of the program while sending back a value at the same time. For example, here we define a function square that returns the square of its parameter, and then we call this function with the value 2. The function returns 4 and this returned value is then printed. def square(x): return x*x print(square(2))
17th Sep 2016, 10:11 PM
Zen
Zen - avatar
0
Thanks
18th Sep 2016, 7:56 AM
Moritz Fotografie
Moritz Fotografie - avatar