Skip to content
BENIBIX Learn

Return Value

Development🧩 Programming ConceptsFunctions

Also known as return, Return Statement

The result a function hands back when done. The return line sends it out.

Think of it like

Think of it like a vending machine dropping your snack. You put coins in, and one thing comes back out.

Example

add_tax(10) returns 12.0. The checkout page stores that in total and shows it to the buyer.

Why it matters

Return values let functions feed each other. One function's answer becomes the next one's input.

Definition

A return value is the result a function hands back when it finishes. The return line sends it out and ends the function at once. The code that called the function can then store it or use it. A function with no return line gives back nothing, which Python shows as None. Returning a value is not the same as printing it on the screen.

Example code

python
def add_tax(price):
    return price * 1.2

total = add_tax(10)
print(total)   # 12.0
The function hands back 12.0, and the caller keeps it in total.

Common mistake

Printing a result instead of returning it. The screen shows the number, but the rest of the program gets None.

Key takeaways

  1. 1
    Hands back a result. The caller can store or use it.
  2. 2
    Ends the function. Nothing after return runs.
  3. 3
    Not the same as print. Print shows it; return gives it.

Learn it properly