Module 4 - Section 1 - While and Functions
4.1.6 - Return from a Function
Return vs Print
Certain functions, such as int or str, return a value that can be used later. When a function returns a value the value is not printed in the output.
To return a value for your defined functions, you can use the return statement. The return statement cannot be used outside of a function definition.
Write the following code to Thonny script editor and save it as maxOfTwo:
The function takes two arguments and returns the maximum of two without printing anything.
Execute the code and in CLI write the following commands and observe the Variables area :
>>> print(max(3,9))
>>> z = max(11,2)
>>> print(z)