A function return value is the data a Python function sends back to the caller after it finishes. That data can be a number, text, a list, a tuple, or None. Printing only shows something on the screen. Returning gives later code something real to work with. That difference trips up a lot of students in programming in python. A function that prints "12" may look useful, but another line of code cannot reuse that text unless the function returns it. A function that returns 12 can feed math, tests, and conditionals on the next line. That is why function return values in python are such a big deal. Think about a simple grade calculator, a tax helper, or a name-cleaning function. If each one returns a value, the next step can store it in a variable, compare it against 70, or pass it into another function. If each one only prints, the result dies on the screen. That limits you fast. Students in a programming in python course often mix up output and return because both can show numbers. They do different jobs. Return hands data back to the caller. Print talks to the user. Once you see that split, understanding function return values and usage in python gets much easier, and the code starts acting like parts of a system instead of isolated scraps.
What Are Function Return Values In Python?
A function return value in Python is the piece of data that comes back to the caller after the function runs, and that single result can be a number, text, a list, a tuple, or None. This matters in the first 10 minutes of learning functions, because the caller can save that result in a variable and use it on the next line instead of staring at screen output.
The catch: a function can do work for 20 lines and still give back just one value at the end, so the real question is not how much code it runs but what data it returns. A calculator function might return 18 after adding 7 and 11, while a name-cleaning function might return "Maya Lee" after trimming spaces from " Maya Lee ". That return value becomes part of the program’s flow, not just a message.
This is where students often slip. They think "the function worked" because they saw text print once, but later code cannot use printed text the way it can use a returned result. In programming in python, return values let one function become the input for another, which is how you build small pieces that work together. A function that returns a total can feed a discount function, a pass/fail check, or a chart, and each step can use the result without repeating the original math.
A clean example helps. If a function returns 25, you can write `price = total_cost()` and then use `price` in a comparison like `price > 20`. If the function only prints 25, that line gives you nothing to compare. That limitation feels small in a 1-line demo, but it gets messy fast in a 200-line script.
Reality check: return values also help testing because you can check one exact output instead of reading a screen dump. A test can ask for 42 and compare it with 42 in under 1 second, which makes bugs easier to spot than scrolling through 15 printed lines.
How Do Python Return And Print Differ?
Return and print both move information, but they do not play the same role. Return sends a value back to the caller, and print shows text to a person. That difference matters because Python stops running the function body the moment it hits `return`, so any code after that line does not run.
| Column 1 | Column 2 | Column 3 |
|---|---|---|
| Purpose | return | |
| Where output goes | caller / next line | screen or console |
| Reusable later? | yes | no |
| Stops function? | yes, immediately | no |
| Example | `x = add(2, 3)` | `print(add(2, 3))` |
| After line | `x` holds 5 | nothing to store |
| Code after statement | runs only before return | keeps running |
What this means: `return` feeds the next line of code, while `print` just displays a result and leaves you with no usable object. If a function says `return 9`, the caller can do math with 9 right away. If it says `print(9)`, you get a display and no value to pass forward.
That is why a lot of beginners get burned by "it prints, so it must be correct." Nope. The console can fool you.
Learn Programming In Python Online for College Credit
This is one topic inside the full Programming In Python course on UPI Study — a self-paced, online class that earns real college credit. Credits are ACE and NCCRS evaluated and transfer to partner colleges across the US and Canada. Courses start at $250 with no deadlines and lifetime access.
Browse Programming In Python →Why Does Returning Data Matter In Python?
Returning data matters because it lets one function hand a result to another function, which is how reusable code starts to look clean instead of tangled. A `clean_name()` function can return "Ana Gomez", and then a `make_email()` function can use that result to build an address in 2 steps instead of repeating the cleanup logic.
Bottom line: return values make code testable, and testable code saves time. A unit test can compare one returned score against a threshold like 70, 80, or 90 without reading console noise. That is a real benefit in programming in python, especially when you build tools that need exact answers instead of just a message for the user.
You also use return values inside `if` statements, which makes logic sharper. A function can return `True` when a file size stays under 5 MB, and the caller can decide what to do next. That pattern shows up everywhere: login checks, grade checks, discount rules, and API calls.
This is where understanding function return values and usage in python becomes foundational, not optional. If you learn it early, your code stops acting like one-off scripts and starts acting like parts that talk to each other. That shift matters in a programming in python course because later lessons on classes, errors, and file handling all assume you know how data moves back from a function.
A weak return strategy causes weird bugs. A function that prints a number but returns nothing leaves the caller stuck with `None`, and that can break math on line 48 even though line 12 looked fine.
How Do You Return Single Or Multiple Values?
Python lets you return one value, two values, or ten values, and the caller can unpack them into separate names in the next line. Under the hood, multiple values come back as a tuple, which is neat and a little sneaky.
- Start with one value when you only need one answer, like `return 12` from a total-price function.
- Store that result right away, because a variable like `total = get_total()` gives you a real value to use in 1 second or less.
- Return two values when the caller needs both, such as `return first_name, last_name` from a cleanup function.
- Unpack them on the next line, like `first, last = get_name()`, and Python splits the tuple into two names without extra steps.
- Use three values when the job calls for it, like `return min_score, max_score, average`, but keep the shape simple so later code does not turn into a guessing game.
- Watch your thresholds. If a value must stay above 50 or below 100, returning it cleanly lets the caller check that rule right away instead of parsing printed text.
Worth knowing: the caller can unpack a 2-item tuple in one line, but Python still returns one object first. That small detail matters in debugging because a line like `x, y = get_coords()` fails if the function returns only 1 value or 3 values.
A good habit helps here: return data in the same order every time. Swapping `lat, lon` on one call and `lon, lat` on another call wastes time fast, even in a tiny 4-line example.
What Does None Mean In Python Returns?
A function that ends without an explicit `return` gives back `None` by default, and that happens even if the function printed 5 lines of output. `None` means "no useful value," not 0, not `""`, and not `False`.
- A plain function like `def greet(): print("Hi")` returns `None`, so the caller cannot do math with it.
- `return None` can be deliberate when a function has nothing meaningful to give back, like a search that found no match after 3 tries.
- Do not confuse `None` with 0. A balance of 0 dollars still means something real, while `None` means the function gave no result at all.
- Do not confuse `None` with an empty string. `""` is text with 0 characters, and `None` is a different Python object.
- A printed value cannot drive later code by itself, so `print(score)` in line 8 gives you display only, not a reusable answer.
- A missing return often causes bugs that show up later, like `TypeError` when line 22 tries to add `None + 5`.
- Check `None` on purpose when a function may fail, because that keeps your logic honest and makes the failure clear fast.
Frequently Asked Questions about Python Return Values
A Python function return value is the data a function sends back with `return`, and one function can return 1 value, 2 values, or `None`. In programming in Python, that return value becomes the next line’s input, so you can store it, compare it, or use it in a math step.
Start by deciding whether you want to show text or give data back. `print()` sends output to the screen, while `return` sends a value back to the caller, and that caller can save it in a variable, use it in a `if` test, or pass it into another function.
What surprises most students is that `return` ends the function right away, while `print()` does not. If a function hits `return 10`, Python stops there and gives `10` back, which matters in a programming in Python course when you chain results across 2 or 3 steps.
Most students print a result and then try to use that printed text later, but that does not work. What works is saving the return value in a variable, like `total = add(4, 5)`, so you can use `total` in the next line, the next function, or a comparison.
You return a single value with one `return` statement, like `return 42` or `return name`. The caveat is that the function stops right there, so any code under that line never runs, and that matters when you want clean college credit work in an online course.
The most common wrong assumption is that `print()` and `return` do the same job. They don't, because `print()` only shows output, while `return` gives a value back that you can reuse for ACE NCCRS credit work, study online labs, and other transferable credit tasks.
If you get them wrong, your code may show the right answer on the screen but still fail on the next line. That breaks later steps in programming in Python, like checking a score, adding two numbers, or sending data to another function.
This applies to anyone learning Python 3, from first-time coders to students in a programming in Python course, and it doesn't apply if you're only trying to display text with `print()`. Return values matter when you need data back, not just screen output.
You return multiple values by writing them with commas, like `return a, b`, and Python packages them as a tuple. That means you can unpack 2 values at once, which helps when you need a score and a grade, or a total and a count.
`return None` means the function gives back no useful value, and Python also uses `None` when you leave off `return` completely. You still get a real result object, so you can test for `None` before using it in later code.
Final Thoughts on Python Return Values
A return value is not just a small Python detail. It is the handoff point between one part of your program and the next, and that handoff changes everything about how clean, testable, and reusable your code feels. Once you separate return from print, a lot of beginner confusion drops away fast. The best habit is simple: ask what the function should give back before you write the body. If the caller needs a number, return a number. If it needs two pieces of data, return both. If it needs nothing, say that plainly and use `None` on purpose. That habit keeps your code honest. Watch for the trap where a function prints the right thing but returns nothing. That bug looks small in a 3-line example and ugly in a 300-line script. A printed result helps the person at the keyboard, but a returned result helps the program keep moving. If you are just starting out, practice with tiny functions first: one that adds 2 numbers, one that returns a full name, and one that returns `None` on purpose. Then test what happens when you store the result, compare it, and pass it into another function. That is where the lesson sticks. Write the next function with one clear return value in mind, then check what the caller does with it on the very next line.
How UPI Study credits actually work
Ready to Earn College Credit?
ACE & NCCRS approved · Self-paced · Transfer to colleges · $250/course or $99/month