# return statement = Functions send Python values/objects back to the caller. # These values/objects are known as the function’s return value def multiply(number1,number2): return number1 * number2 x = multiply(6,8) print(x)
I've been struggling to fully understand return statements. I get their main purpose is to return a value, but I didn't understand how to use it fully. This has helped.
I've taken several coding courses, no one has properly explained the return statement. They always say something like, "And this will return the value outside of the function" and I'm always like, wtf does that even mean. So glad I finally found this video. Super good explanation, very very simple. I FINALLY UNDERSTAND THE RETURN STATEMENT
I still dont get it, check this both codes and for me i dont understand the use rn def math( a , b): print (a * b) math( 3 , 3 ) 9 def multiply( num1 , num2 ): return num1 * num2 print(multiply( 3 , 3 )) 9 I used return on one and not the another and is still giving me the same answer. I wonder if I didn't get the definition right
@@yo1077 The best explanation I've found is: def printAndReturnNothing(): x = "hello" print(x) def printAndReturn(): x = "hello" print(x) return x def main(): ret = printAndReturn() other = printAndReturnNothing print("ret is: %s" % ret) print("other is: %s" % other) if __name__ == "__main__": main() Output: hello hello ret is : hello other is: None
@@jerrylopez153 I think I know the difference between your two pieces of code. Both of them work with what you are trying to do, but the second piece of code where you use the return statement works for more things. For the second piece of code, the result being the number 9, is now stored within the function as opposed to the first one. This can be very handy when you need to work with the result of that operation later on in the function. As an example, you could store that multiply value in a variable, let's call it x, and then if you want to print a comparison Boolean operation, where you say x == 9, then the program could return whether that's true or false, for a homework checker program for instance. With that first piece of code, you wouldn't be able to do that, because the function did not store that value, so you cannot keep working with the result later on.
What I’m getting is that you have some function or functions that do some stuff you want done, and then, you have the final result of those operations stored in the returned variable. Now, you can do other stuff with that variable in other parts of your code.
Basically “return” is only used in a function. Also using “return” let’s you assign the function to as many variables as you want. Assigning “print” to a variable you get the value but also the word “None”. def math (x, y): Return x + y cat = math(3, 2) dog = math(5, 5) bat = math(1, 2) print(cat) print(dog) print(bat) 5 10 3
GOD. SENT. LITERALLY. CODING IS NOT DIFFICULT. PPL JUST MAKE IT SEEM DIFFICULT. YOU EXPLAINED IT LIKE POETRY IN LIKE WHAT 4 MINS. THANK U U UU U U U U U U U UU U
im new in python and its really confusing for me, why use return when you can directly print the result, both are doing the same thing, but print is more straight forward
I am a computer science student. I understand everything you say, do as like you, you explain it much better than our professors, but i cannot do the exercises which I get from the university, yet. WHY? I am crying!!
I've been a lead developer at Oracle for over 6 months and still have very little comprehension on what a return statement does. I am scared to tell my employees, are you free to help me 1 on 1 on this topic, you seem very knowledgeable.
hey bro , so i have this question : What is the differnce between this code : def multiply(num1,num2): result = num1 * num2 print(result) multiply(8,6) and this : def multiply(num1,num2): result = num1 * num2 return(result) print(multiply(8,6))
@@xplatform2642 we can say that it makes no sense for the types of questions like this but if you have too many codes and probally same codes and you have to make one of them variable and more , i'm actualy a biggener too you can join the discord servers and watch their codes so you will be better
Thanks i spend 2 hours to understand those, becouse guy that im learing from can't teach i think xD But i spent money (not much actualy) and before he explained other stuff good
I do not know why my brain isn't grasping this even though I can tell you explained this very well haha. This is frustrating I'm sure I'm making it more complex then it needs too. Maybe I'm not understanding why you would use this I guess. So when you call the function: multiply() with the input numbers of 6 and 8. its running through the function and multiplying the 6 and 8 and the return is what? Taking that 48 and returning it to the x assigned to the function(multiply)?
this got me thinking as well. I am wondering the same thing! who's calling? who's the caller? I am assuming that the multiply function is the one calling/the caller.
# return statement = Functions send Python values/objects back to the caller.
# These values/objects are known as the function’s return value
def multiply(number1,number2):
return number1 * number2
x = multiply(6,8)
print(x)
What does "the caller" here mean actually? 😵💫
@@minhchientruong2973 same question. i hope he replies
Bro Code, i still don't understand the "return" statement. "return to the caller"? what's that used for? i'm so confused
@@bjfrix sunny the caller is the func name you use it call func:))
1:48
"6 times 8 is really great, 6 times 8 is 48"
BARS
DAMN
I'm 2 years late. 😅
call him barbie cause he got bars 🙅♂
Thanks man, I appreciate how short and to the point your tutorials are
Thank you. The return statement was my nemesis for a very long time.
I've made an entire game using pygame and still was unsure how Return worked, I guess I just survived using using global variables when necessary
The return statement will come for us all in the end.
@@josiahscarrmusic6750can you tutor me still I don’t understand
Metoo.😂 but I get it now
I finally understand return !
I struggled so much (I even get decouraged and made a long pause from learning python) !
Thank you so much !!!
me too
@@alanlado1602can you still teach me some stuffs on python
I understood from you in 3 minutes what I couldn't understand even after spending 30 minutes with others
I've been struggling to fully understand return statements. I get their main purpose is to return a value, but I didn't understand how to use it fully. This has helped.
I've taken several coding courses, no one has properly explained the return statement. They always say something like, "And this will return the value outside of the function" and I'm always like, wtf does that even mean. So glad I finally found this video. Super good explanation, very very simple. I FINALLY UNDERSTAND THE RETURN STATEMENT
i dont actully understand
one of the best on youtube!
I finally understand return statements after watching multiple videos. Glad I came across this one thank you thank you thank you
I still dont get it, check this both codes and for me i dont understand the use rn
def math( a , b):
print (a * b)
math( 3 , 3 )
9
def multiply( num1 , num2 ):
return num1 * num2
print(multiply( 3 , 3 ))
9
I used return on one and not the another and is still giving me the same answer. I wonder if I didn't get the definition right
@@jerrylopez153 exactly!! I really don’t get the point of it.. why use return?
@@yo1077 The best explanation I've found is:
def printAndReturnNothing():
x = "hello"
print(x)
def printAndReturn():
x = "hello"
print(x) return x
def main():
ret = printAndReturn()
other = printAndReturnNothing
print("ret is: %s" % ret)
print("other is: %s" % other)
if __name__ == "__main__":
main()
Output:
hello
hello
ret is : hello
other is: None
@@yo1077 I think return is to give back such value back to the caller so that you can do whatever with that returned value.
@@jerrylopez153 I think I know the difference between your two pieces of code. Both of them work with what you are trying to do, but the second piece of code where you use the return statement works for more things. For the second piece of code, the result being the number 9, is now stored within the function as opposed to the first one. This can be very handy when you need to work with the result of that operation later on in the function. As an example, you could store that multiply value in a variable, let's call it x, and then if you want to print a comparison Boolean operation, where you say x == 9, then the program could return whether that's true or false, for a homework checker program for instance. With that first piece of code, you wouldn't be able to do that, because the function did not store that value, so you cannot keep working with the result later on.
nice tutorial, helped me clear my doubt between print and return statement
even i had the same doubt
I just dont understand what is return statement used for.
i think return statement makes the function's value becomes the returned value
return statements play a major role whenever you want to store the result
Either do in😢
What I’m getting is that you have some function or functions that do some stuff you want done, and then, you have the final result of those operations stored in the returned variable. Now, you can do other stuff with that variable in other parts of your code.
Bro, your tutorials have been super helpful to me
Keep up the good work
You made learning the return statement very easy to understand.
Thanks. 💯
luv u bro
i made a game in python
in my dream
😭😭😭😭😭😭😭😭😭
Amazing explanation! Thanks.
oh my gosh, I understood this way better than frickin german tutorials xD, thank you so much
thanks mate. was struggling a lot with return statement.
Thanks for being straightforward . I was able to catch fast
commenting to support this channel !!!
THANK YOU! YOU SAVED MY LIFE!!!!! I LOVE YOUUUUUUUUUUUU!!!!!!!!!!!!!!
my bro fr FR
Thank you very much I am getting smarter everyday with you
You've earned another subscriber
I love your videos Bro!!!!!
watched 3 videos, didnt understand anything, watche yours, didnt understand either
Basically “return” is only used in a function. Also using “return” let’s you assign the function to as many variables as you want. Assigning “print” to a variable you get the value but also the word “None”.
def math (x, y):
Return x + y
cat = math(3, 2)
dog = math(5, 5)
bat = math(1, 2)
print(cat)
print(dog)
print(bat)
5
10
3
thanks, i already found a youtuber who explained it well, but still yours was also very good@@joeb895
@@satothdo you remember his name?
GOD. SENT. LITERALLY. CODING IS NOT DIFFICULT. PPL JUST MAKE IT SEEM DIFFICULT. YOU EXPLAINED IT LIKE POETRY IN LIKE WHAT 4 MINS. THANK U U UU U U U U U U U UU U
I like the way you teach. Thanks!
Thanks bro, I finally got to understand the return statement! Keep up the good work!
Question: What font and theme are you using?
your videos are the best Bro, much appreciated
Thank you
Helped me understood this, thanks.
thanks bro for clear understanding of any concept...
This video is the only video on RUclips that helped me learn return statements! Thank you!
thanks bro, im a noob and this was really helpful
Thanks!!!! Clear and effective.
Great stuff bro!
Short and sweet. Really helpful
very simple to understand ty
Thanks this helped me alot.
Good explanation bro
Thanks man , very helpful stuff
great video
amazing, it easily explained it
Thumbs up 👍 bro
short and well explained. perfect
very nice lesson
Well well well..i followed the EZ steps! Smashed the like button , dropped the comment and also subscribed 🫂🫂🫂
excellent job man
Thank you, it's starting to make sense
very helpful
Thank you gor lesson
you know that a python statement is hard to learn when you cant even understand it with bro code
good stuff, thanks
great work
Thanks for the video!
Thanks, this took me a while to grasp for some reason, i'm a total noob to coding , hehe
Are you still coding or did you decide to narrate in veggie tales instead😅
Great stuff
Useful
Thanks for the help
im new in python and its really confusing for me, why use return when you can directly print the result, both are doing the same thing, but print is more straight forward
bro same, that's what I'm thinking. I cannot understand the main purpose of 'return'.
Me too, was wondering why I have to go through all that stress when I can just print it 😭
you are the best
Great!
🎉❤thanks brocode
thanks for this ,it was helpful
Fantastic
Amazing zing zing
A good explaination
Nice
straightforward and informative, may I suggest a less deafening keyboard?
Helpful
Good
Thanks for the video bro
that's amazing
I am a computer science student. I understand everything you say, do as like you, you explain it much better than our professors, but i cannot do the exercises which I get from the university, yet. WHY? I am crying!!
Wonderful
GLife
Left the link to your play lists in my last discussion post.
good
ayoko nga. char, eto na nga! eto namn, joke lang eh BWAHAHAHAHA
I've been a lead developer at Oracle for over 6 months and still have very little comprehension on what a return statement does. I am scared to tell my employees, are you free to help me 1 on 1 on this topic, you seem very knowledgeable.
hey bro , so i have this question : What is the differnce between this code :
def multiply(num1,num2):
result = num1 * num2
print(result)
multiply(8,6)
and this :
def multiply(num1,num2):
result = num1 * num2
return(result)
print(multiply(8,6))
the output is the same 48 for both codes
@@xplatform2642 So why do it with a return function?
@@xplatform2642 we can say that it makes no sense for the types of questions like this but if you have too many codes and probally same codes and you have to make one of them variable and more , i'm actualy a biggener too you can join the discord servers and watch their codes so you will be better
@@Haryad-nh5kc its good to ask questions, programming is not easy to understand when you dont see the logic behind the code.
@@mikeb3717 Return basically tells the computer that the function is over. Print doesn't.
Thanks i spend 2 hours to understand those, becouse guy that im learing from can't teach i think xD But i spent money (not much actualy) and before he explained other stuff good
I do not know why my brain isn't grasping this even though I can tell you explained this very well haha. This is frustrating I'm sure I'm making it more complex then it needs too. Maybe I'm not understanding why you would use this I guess.
So when you call the function: multiply() with the input numbers of 6 and 8.
its running through the function and multiplying the 6 and 8 and the return is what?
Taking that 48 and returning it to the x assigned to the function(multiply)?
Thanks fellow Bro!
Bro is great
Awesome man thanks
helpful thank you :)
Thank you ❤️
thank u bro
Sup bro
thank you bro code !!
Thanks bro!
This channel is so good i just can't not return here
love u my bro
useful
Thanks Bro!!
I’m sorry, can I ask who’s calling? Lol in other words who is “the caller” in this example?
this got me thinking as well. I am wondering the same thing! who's calling? who's the caller? I am assuming that the multiply function is the one calling/the caller.
in order for a function to execute its code it has to be called .
example:
def caller():
print("Lily berry")
caller()
6 times 8 is really great 6 times 8 is forty 8. that got me
besttt
thank you!
cool!
ooo-waaa