Return Function | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

Return Function

please, can one help me to know what return do and meaning in python? < I searched very much and did not understand well >

25th Jun 2020, 10:27 PM
Amr Khaled
Amr Khaled - avatar
3 Réponses
+ 3
When you write a piece of code which will generate a result, that you may wish to integrate later into another piece of code, then *return* is ideal.
25th Jun 2020, 11:20 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
Return statement makes a function call to terminate and to evaluate a value, which value is evaluated is specified by the argument of the return statement. When you use operations, program solves them 1 operation at time: (((5 + 9)*4) - 6) -> ((14*4) - 6) -> (56 - 6) -> 50 Operations use values (operands) to generate new values, functions work very similarly, functions use values (arguments) to generate new values.
25th Jun 2020, 11:38 PM
Seb TheS
Seb TheS - avatar
+ 2
I have a little snippet which may help you understand a bit better def example(x): return x**2 +1 print(example(2)) print(example(3)) print(example(2)* example(3))
25th Jun 2020, 11:24 PM
Rik Wittkopp
Rik Wittkopp - avatar