I'm new to programming and keep seeing the terms "output" and "return." Some explanations say that return is meant for the computer, while output is meant for a person. Is output something displayed on the screen, while return stores a result for the program to use? If a function calculates 2 + 3, for example, what does `return` actually do, and how is that different from putting the result in a variable?
3 Answers
“Output” is a broad word and can mean anything a program produces, including text on the screen, sound, a file, or even a value from a function. In everyday beginner examples, though, output usually means displaying something with a command such as `print`. “Return” specifically describes a function giving a value back to the code that called it. A returned value can be used for further processing, while displayed output is mainly for communication or logging.
Think of a function like a calculator. A returned value is the calculator handing the answer back to the person or code that asked for it. You can then do something like `total = add(2, 3)` or `print(add(2, 3))`. Printing is more like the calculator displaying “5” on its screen: it communicates the result, but it doesn’t make that result available to the rest of the program in the same way.
They’re different operations. Printing sends information outside the running program, usually to the screen or a file, so a person or another tool can see it. Returning gives a value back to the code that called a function, allowing the program to store it or use it in another calculation. For example, `function add(a, b) { return a + b; }` lets you write `x = add(2, 3)`, so `x` becomes 5. If the function only printed 5, you would see 5, but the program would not automatically receive 5 as a usable result.
So `return` doesn’t loop or save the value by itself. It hands the value back to the caller, and the caller can decide whether to store it in a variable, pass it to another function, or use it immediately.

A simple way to compare them is: `print(add(2, 3))` displays the answer, while `result = add(2, 3)` returns the answer and stores it in `result`. You can also do both if you want to calculate with the value and show it to the user.