Common Statements Flashcards
1
Q
The return statement: What does it do?
A
The return statement is used inside a function to send a value or result back to the place where the function was called. It effectively ends the function’s execution and optionally provides an output.
Key Features of return
Terminate a Function:
When return is executed, the function stops running, and control is passed back to the caller.
Provide a Value:
You can include an expression or value with return, which will be sent back to the caller.
If no value is provided, the function returns None by default.