Return statement
A return statement ends the current function or routine invocation and optionally supplies its result to the caller.
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.
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.
Related concepts
- yieldcontrasts with · A language construct that yields control from a computation, optionally passing a value to another context, and may allow the suspended computation to continue later.
- return valueconfigures · A return value is the result produced by a function, method, or operation and supplied to the code that invoked it.
- Noneproduces · None is Python’s singleton object representing the absence of a value or meaningful result.
- functionused by · A function is a callable program unit that performs an operation, may accept inputs, and can produce a result or side effect.
- throwcontrasts with · A throw construct explicitly raises or propagates an exception, error, or value to transfer control nonlocally from normal execution.
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.




