📚 College Credit Guide ✓ UPI Study 🕐 12 min read

What Are Function Return Values In Python?

This article explains Python return values, how they differ from print, and how returned data drives later code with single, multiple, and None results.

US
UPI Study Team Member
📅 September 12, 2026
📖 12 min read
US
About the Author
The UPI Study team works directly with students on credit transfer, degree planning, and course selection. We've helped thousands of students figure out what counts toward their degree and how to finish faster without paying more than they have to. This post is written the way we'd explain it to you directly.
🦉

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.

High-resolution image of colorful programming code highlighted on a computer screen — UPI Study

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 1Column 2Column 3
Purposereturnprint
Where output goescaller / next linescreen or console
Reusable later?yesno
Stops function?yes, immediatelyno
Example`x = add(2, 3)``print(add(2, 3))`
After line`x` holds 5nothing to store
Code after statementruns only before returnkeeps 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.

Programming In Python UPI Study Course

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.

  1. Start with one value when you only need one answer, like `return 12` from a total-price function.
  2. Store that result right away, because a variable like `total = get_total()` gives you a real value to use in 1 second or less.
  3. Return two values when the caller needs both, such as `return first_name, last_name` from a cleanup function.
  4. Unpack them on the next line, like `first, last = get_name()`, and Python splits the tuple into two names without extra steps.
  5. 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.
  6. 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`.

Frequently Asked Questions about Python Return Values

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

More on Programming In Python
© UPI Study. This article and its educational content are solely owned by UPI Study and licensed under CC BY-NC-ND 4.0. It is not free to reuse or modify. Any citation must credit UPI Study with a direct link to this page.