10.1.1 The Return Keyword

A function doesn’t always have to display its output directly. Instead, it can process some data and then return a value or set of values. The value the function returns is called a return value. The return statement takes a value from inside a function and sends it back to the line that called the function. Return values allow you to move much of your program’s grunt work into functions, which can simplify the body of your program. (Python Crash Course 2nd Ed., Eric Matthes, p.137, 2019)

The return keyword is used to specify the output of a function. We write the keyword return followed by an expression (remember that an expression can, but doesn’t have to, be a lone variable or literal value); the value of the expression is the result that your function is "sending back" to wherever it was called from in your program.

You can create your own functions that return a value:

For example, here is a function that calculates the area of a square and returns the answer.

Let’s make a simple function which returns a value, but doesn’t require an argument to run. We’ll make a function that takes a value in inches and converts it into centimetres: