What exactly is the return function ? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 5

What exactly is the return function ?

I wanna say_ How is return function different from print function ?

28th Apr 2021, 2:47 AM
M Umer
M Umer - avatar
9 Antworten
+ 4
M Umer print displays the content to the console, return returns the value to a variable so you can use the value it just returned later in the program. in other words. print is just to print and return is to return a value.
29th Apr 2021, 8:57 PM
ÔŁĄ´ŞĆ­čśŹPrerana­čśŹÔŁĄ´ŞĆ
ÔŁĄ´ŞĆ­čśŹPrerana­čśŹÔŁĄ´ŞĆ - avatar
+ 8
here's a code example to Jan's explination: https://code.sololearn.com/cpGThocHw9cA/?ref=app
28th Apr 2021, 3:12 AM
Slick
Slick - avatar
+ 7
each function is a return function. By default it returns None. If you want another value u need a return statement. Besides returning sth. functions can do other stuff: printing, saving files... whatever.
28th Apr 2021, 4:57 AM
Oma Falk
Oma Falk - avatar
+ 2
Great explanation ­čÖî
28th Apr 2021, 3:19 AM
M Umer
M Umer - avatar
+ 2
For example you can make a deal with return
28th Apr 2021, 3:57 AM
Shadoff
Shadoff - avatar
+ 1
Thank You_ but what can we do else with return, for example..
28th Apr 2021, 3:06 AM
M Umer
M Umer - avatar
+ 1
The return statement is NOT a function. It goes inside one at the end. As of Python 3, print IS a function. This question is harder to answer because the SoloLearn interpreter basically uses input() like function parameters for the whole program, and it uses print() like a return statement for the whole program. In normal Python (ie on a PC), these functions display text on a console as they are called, and the input() function waits for the user to enter something before continuing, which it then returns as a string. In short, return is a statement that goes inside functions when you want them to spit something out when theyÔÇÖre done. Print is just for showing some output to the user and cannot give output to the rest of the program. Print() and input() are the program to user communicator functions, return and ÔÇťparametersÔÇŁ are the inner function program scope to outer program scope communicatorÔÇŽ statement/format thigies.
29th Apr 2021, 11:26 AM
Wilbur Jaywright
Wilbur Jaywright - avatar
17th Dec 2023, 3:02 AM
Khusnul Khotim
Khusnul Khotim - avatar
- 2
int k=10; k= k++; System.out.printl(k); Output in Java ??
29th Apr 2021, 12:18 PM
Abhishek
Abhishek - avatar