The example in this article describes the use of return statements in Python. Share to everyone for your reference. Specific as follows:
Return statement:
The return statement is used to return a function from a function. We can also choose to return a value from the function.
Use a literal statement
#!/usr/bin/python# Filename:func_return.pydef Maximum (x, y): if x > y: return x else: return yprint Maximum (2, 3)
Output
$ python Func_return.py3
Working principle:
The maximum function returns the maximum value in the parameter, which is the number provided to the function. It uses the simple if: Else statement to find a larger value, and then return that value.
Note that a return statement with no return value is equivalent to return none. None is a special type of Python that represents nothing. For example, if a variable has a value of none, you can indicate that it has no value.
Unless you provide your own return statement, each function contains a return none statement at the end. By running print someFunction (), you can see that the function someFunction does not use the return statement as follows:
Def someFunction (): Pass
The pass statement represents an empty block of statements in Python.
Hopefully this article will help you with Python programming.