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 >
3 ответов
+ 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.
+ 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.
+ 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))