liveBook · Manning

Return statement

A return statement ends the current function or routine invocation and optionally supplies its result to the caller.

How 5 Manning books explain it

A Pythonic Adventure: From Python basics to a working web app

A return statement exits a function and optionally supplies a result to its caller.

How it is used
Uses return statements to pass selected menu items and collected order data from functions to the main program.
How deep it goes
Explains function scope and returned values through complete menu and order examples, without exploring return control flow beyond these cases.
Examples
Uses a coffee-shop menu that returns a chosen item and an order function that returns a customer dictionary.
What you can do after
Build it from scratch by writing functions that return menu selections or collected order data to calling code.

Read how A Pythonic Adventure: From Python basics to a working web app explains return statement →

Get Programming: Learn to code with Python

A statement that terminates a function's execution and optionally supplies a value to its caller.

How it is used
Uses `return` to finish a function call and supply a result the caller can use.
How deep it goes
Explains early termination, implicit `None`, tuple results, and returning function objects without detailing interpreter internals.
Examples
Contrasts printing and returning names, returns a joined string’s length, and unpacks addition and subtraction results.
What you can do after
Build it from scratch: write functions whose results can be assigned, printed, or unpacked by a caller.

Read how Get Programming: Learn to code with Python explains return statement →

Python How-To

A return statement terminates a function and optionally supplies a return value to its caller.

How it is used
Uses return to define function outputs, stop execution, and pass results through decorators.
How deep it goes
Explains implicit, bare, single, and multiple returns, then examines decorator control flow and finally-clause precedence.
Examples
Demonstrates None results, greeting and statistics functions, decorator wrappers, and competing returns in try/finally.
What you can do after
Apply it via Python to design function outputs, forward decorated results, and predict control flow around finally clauses.

Read how Python How-To explains return statement →

Learn AI-Assisted Python Programming, Second Edition

A return statement ends a function execution and optionally provides a value as the function's output.

How it is used
Uses return to pass a function’s answer to its caller during problem decomposition.
How deep it goes
Explains return through function outputs, conditional examples, and calls, but does not detail execution internals.
Examples
Uses a larger-number function, Python’s max function, and input returning a user’s typed name.
What you can do after
Apply it via Python functions to send computed answers back, store results, and test behavior across inputs.

Read how Learn AI-Assisted Python Programming, Second Edition explains return statement →

Modern C

A return statement is a C control-flow statement that ends execution of the current function and optionally supplies a return value.

How it is used
Coordinates function calls by ending a function and resuming execution at its caller.
How deep it goes
Defines control transfer, typed expressions, multiple returns, and closing-brace behavior, but defers implementation internals.
Examples
Uses main returning EXIT_SUCCESS, printf returning to main, and leapyear returning a Boolean expression.
What you can do after
Apply it via C syntax to return control and correctly typed values from functions.

Read how Modern C explains return statement →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.