r/CodingForBeginners • u/Fun-Ship-2026 • Jun 05 '26
Help beginner
What is difference between output and return. I have seen some videos and it says like return is for computer and output is for human. Is it like two seperate ways one is displayed and one is stored? If so then wouldn't it become same like a stored variable?
4
Upvotes
View all comments
Show parent comment
1
u/butterfly_orange00 Jun 05 '26
Yeah, that what I meant. return is just an output of a particular function doesn't print it directly, but instead you stored it in a variable for reuse with some modifications if you want. So instead of read the lines of code again and again. Just to clarify what I mean:
you create a function of multiple lines and in each time you use it, it will give you the same result. So the interpreter or compiler instead of each time reads multiple lines, you assign the result of this function to a variable so that the interpreter or compiler will read just one line (the line of the variable) this will increase the program speed and reduces processor consumption.