Python return statement 🔙

Поделиться
HTML-код
  • Опубликовано: 24 янв 2025

Комментарии • 221

  • @BroCodez
    @BroCodez  4 года назад +43

    # 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)

    • @minhchientruong2973
      @minhchientruong2973 2 года назад +1

      What does "the caller" here mean actually? 😵‍💫

    • @bjfrix
      @bjfrix 2 года назад

      @@minhchientruong2973 same question. i hope he replies

    • @bjfrix
      @bjfrix 2 года назад

      Bro Code, i still don't understand the "return" statement. "return to the caller"? what's that used for? i'm so confused

    • @pointcodding
      @pointcodding Год назад

      @@bjfrix sunny the caller is the func name you use it call func:))

  • @woah3108
    @woah3108 3 года назад +104

    1:48
    "6 times 8 is really great, 6 times 8 is 48"
    BARS

  • @guitarguy07
    @guitarguy07 2 года назад +35

    Thanks man, I appreciate how short and to the point your tutorials are

  • @lw9954
    @lw9954 2 года назад +49

    Thank you. The return statement was my nemesis for a very long time.

    • @josiahscarrmusic6750
      @josiahscarrmusic6750 2 года назад +5

      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

    • @tmac2483
      @tmac2483 Год назад +7

      The return statement will come for us all in the end.

    • @folarinoyewole1127
      @folarinoyewole1127 Год назад

      @@josiahscarrmusic6750can you tutor me still I don’t understand

    • @diphapangmotholo2455
      @diphapangmotholo2455 3 месяца назад

      Metoo.😂 but I get it now

  • @falopr411
    @falopr411 Год назад +17

    I finally understand return !
    I struggled so much (I even get decouraged and made a long pause from learning python) !
    Thank you so much !!!

  • @فلكالشاهين
    @فلكالشاهين Год назад +4

    I understood from you in 3 minutes what I couldn't understand even after spending 30 minutes with others

  • @beng6319
    @beng6319 2 года назад +3

    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.

  • @aaronwaterman3888
    @aaronwaterman3888 Год назад +6

    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

  • @hul8376
    @hul8376 3 года назад +4

    one of the best on youtube!

  • @gaminggoddessaria
    @gaminggoddessaria 3 года назад +5

    I finally understand return statements after watching multiple videos. Glad I came across this one thank you thank you thank you

    • @jerrylopez153
      @jerrylopez153 2 года назад +4

      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
      @yo1077 2 года назад +1

      @@jerrylopez153 exactly!! I really don’t get the point of it.. why use return?

    • @bwknowles98
      @bwknowles98 2 года назад

      @@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

    • @manifestbruhlol
      @manifestbruhlol 2 года назад +2

      @@yo1077 I think return is to give back such value back to the caller so that you can do whatever with that returned value.

    • @JohnSmith-hr7fl
      @JohnSmith-hr7fl Год назад +4

      @@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.

  • @AyushxMenace
    @AyushxMenace 2 года назад +3

    nice tutorial, helped me clear my doubt between print and return statement

    • @nihalMaTh
      @nihalMaTh 2 года назад +1

      even i had the same doubt

  • @paisz3299
    @paisz3299 Год назад +43

    I just dont understand what is return statement used for.

    • @fenidiv4325
      @fenidiv4325 7 месяцев назад +1

      i think return statement makes the function's value becomes the returned value

    • @FORBIDDEN_LORD
      @FORBIDDEN_LORD 6 месяцев назад +9

      return statements play a major role whenever you want to store the result

    • @diphapangmotholo2455
      @diphapangmotholo2455 3 месяца назад

      Either do in😢

    • @SentimentalApe
      @SentimentalApe 5 дней назад

      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.

  • @shamaeelahmed3561
    @shamaeelahmed3561 2 года назад +2

    Bro, your tutorials have been super helpful to me
    Keep up the good work

  • @SatoshiShadowstrike
    @SatoshiShadowstrike Год назад +2

    You made learning the return statement very easy to understand.
    Thanks. 💯

  • @herryypat_1009
    @herryypat_1009 Год назад +1

    luv u bro
    i made a game in python
    in my dream
    😭😭😭😭😭😭😭😭😭

  • @Chirag-o2g6f
    @Chirag-o2g6f 15 дней назад

    Amazing explanation! Thanks.

  • @kaedeharakazuha582
    @kaedeharakazuha582 Год назад

    oh my gosh, I understood this way better than frickin german tutorials xD, thank you so much

  • @fahimahmed2828
    @fahimahmed2828 Год назад +1

    thanks mate. was struggling a lot with return statement.

  • @Sciland23
    @Sciland23 Год назад

    Thanks for being straightforward . I was able to catch fast

  • @nedalalaoui3089
    @nedalalaoui3089 Год назад

    commenting to support this channel !!!

  • @ERROR-k9v
    @ERROR-k9v Год назад

    THANK YOU! YOU SAVED MY LIFE!!!!! I LOVE YOUUUUUUUUUUUU!!!!!!!!!!!!!!

  • @proskillz2337
    @proskillz2337 Год назад +1

    my bro fr FR

  • @HYddRa627
    @HYddRa627 Год назад

    Thank you very much I am getting smarter everyday with you

  • @daradashs9307
    @daradashs9307 2 года назад

    You've earned another subscriber

  • @petulpetul
    @petulpetul Месяц назад

    I love your videos Bro!!!!!

  • @satoth
    @satoth 10 месяцев назад +6

    watched 3 videos, didnt understand anything, watche yours, didnt understand either

    • @joeb895
      @joeb895 9 месяцев назад +2

      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

    • @satoth
      @satoth 9 месяцев назад

      thanks, i already found a youtuber who explained it well, but still yours was also very good@@joeb895

    • @faresfbm6061
      @faresfbm6061 8 месяцев назад

      ​@@satothdo you remember his name?

  • @dude_mude3366
    @dude_mude3366 Год назад

    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

  • @ibericu
    @ibericu 2 года назад

    I like the way you teach. Thanks!

  • @fabian1551
    @fabian1551 2 года назад +2

    Thanks bro, I finally got to understand the return statement! Keep up the good work!
    Question: What font and theme are you using?

  • @Artyon
    @Artyon 2 года назад

    your videos are the best Bro, much appreciated
    Thank you

  • @plushieplaguedude
    @plushieplaguedude Год назад

    Helped me understood this, thanks.

  • @hunt..9577
    @hunt..9577 11 месяцев назад

    thanks bro for clear understanding of any concept...

  • @manugvlogs
    @manugvlogs 2 года назад

    This video is the only video on RUclips that helped me learn return statements! Thank you!

  • @matrixikari
    @matrixikari 2 месяца назад

    thanks bro, im a noob and this was really helpful

  • @danielesibra2169
    @danielesibra2169 Год назад

    Thanks!!!! Clear and effective.

  • @the_finance_guy_is_here
    @the_finance_guy_is_here Год назад

    Great stuff bro!

  • @iamsandaru
    @iamsandaru 2 года назад

    Short and sweet. Really helpful

  • @xbacondreamsx4796
    @xbacondreamsx4796 7 месяцев назад

    very simple to understand ty

  • @chikamalik3260
    @chikamalik3260 6 месяцев назад

    Thanks this helped me alot.

  • @tunelife710
    @tunelife710 Год назад

    Good explanation bro

  • @ZackLouis-us8lc
    @ZackLouis-us8lc 2 года назад

    Thanks man , very helpful stuff

  • @alexreznitsky6338
    @alexreznitsky6338 2 года назад

    great video

  • @lalitadityabyrapuneni7335
    @lalitadityabyrapuneni7335 2 года назад

    amazing, it easily explained it

  • @englishforfunandcompetitio248
    @englishforfunandcompetitio248 5 месяцев назад

    Thumbs up 👍 bro

  • @DioBrando-qj7mw
    @DioBrando-qj7mw 2 года назад

    short and well explained. perfect

  • @nyiaung4963
    @nyiaung4963 9 месяцев назад

    very nice lesson

  • @prekhyasarkar8554
    @prekhyasarkar8554 2 года назад

    Well well well..i followed the EZ steps! Smashed the like button , dropped the comment and also subscribed 🫂🫂🫂

  • @JPVignoli
    @JPVignoli Год назад

    excellent job man

  • @mathewmcfool
    @mathewmcfool 2 года назад

    Thank you, it's starting to make sense

  • @alirezasohrab-m9k
    @alirezasohrab-m9k Год назад

    very helpful

  • @gedluk6997
    @gedluk6997 Год назад

    Thank you gor lesson

  • @AdminRosss
    @AdminRosss Год назад +1

    you know that a python statement is hard to learn when you cant even understand it with bro code

  • @lari8633
    @lari8633 2 месяца назад

    good stuff, thanks

  • @nyimathinley9978
    @nyimathinley9978 9 месяцев назад

    great work

  • @esoheuzamere4501
    @esoheuzamere4501 2 года назад

    Thanks for the video!

  • @zuzoscorner
    @zuzoscorner 6 месяцев назад

    Thanks, this took me a while to grasp for some reason, i'm a total noob to coding , hehe

    • @thecalculator-oh5lw
      @thecalculator-oh5lw 4 месяца назад

      Are you still coding or did you decide to narrate in veggie tales instead😅

  • @eugenecobbah3289
    @eugenecobbah3289 Год назад

    Great stuff

  • @Alick.outdoors
    @Alick.outdoors 2 года назад

    Useful

  • @ianforbes9644
    @ianforbes9644 Год назад

    Thanks for the help

  • @siamakp1207
    @siamakp1207 Год назад +4

    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

    • @sydduu
      @sydduu Год назад

      bro same, that's what I'm thinking. I cannot understand the main purpose of 'return'.

    • @julbeeyaren8483
      @julbeeyaren8483 Год назад

      Me too, was wondering why I have to go through all that stress when I can just print it 😭

  • @theoryofbadr6507
    @theoryofbadr6507 Год назад

    you are the best

  • @happyfrezar2813
    @happyfrezar2813 Год назад

    Great!

  • @diphapangmotholo2455
    @diphapangmotholo2455 3 месяца назад

    🎉❤thanks brocode

  • @nmrsa7331
    @nmrsa7331 2 года назад

    thanks for this ,it was helpful

  • @harshanandantrivedi9412
    @harshanandantrivedi9412 2 года назад

    Fantastic

  • @shilu3078
    @shilu3078 Год назад

    Amazing zing zing

  • @DrBhavaniRaoReddi
    @DrBhavaniRaoReddi 3 года назад

    A good explaination

  • @jeffreyndukwe3869
    @jeffreyndukwe3869 6 месяцев назад

    Nice

  • @sklzthtklz
    @sklzthtklz 2 года назад

    straightforward and informative, may I suggest a less deafening keyboard?

  • @rahuldutta7901
    @rahuldutta7901 3 года назад +1

    Helpful

  • @ahmetaydn4416
    @ahmetaydn4416 2 года назад

    Good

  • @spartanranger
    @spartanranger 3 года назад

    Thanks for the video bro

  • @Artista-dt3ch
    @Artista-dt3ch 4 месяца назад

    that's amazing

  • @baharehkjani6761
    @baharehkjani6761 Год назад

    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!!

  • @abdessamadmostefai7897
    @abdessamadmostefai7897 3 года назад

    Wonderful

  • @WilliamMcDaniel-nr1nx
    @WilliamMcDaniel-nr1nx Год назад

    GLife
    Left the link to your play lists in my last discussion post.

  • @salaramini8887
    @salaramini8887 Год назад

    good

  • @Angelo-xs7ey
    @Angelo-xs7ey 3 года назад

    ayoko nga. char, eto na nga! eto namn, joke lang eh BWAHAHAHAHA

  • @tmac2483
    @tmac2483 Год назад

    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.

  • @xplatform2642
    @xplatform2642 3 года назад +3

    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
      @xplatform2642 3 года назад +2

      the output is the same 48 for both codes

    • @mikeb3717
      @mikeb3717 3 года назад +2

      @@xplatform2642 So why do it with a return function?

    • @Haryad-nh5kc
      @Haryad-nh5kc 3 года назад +1

      @@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

    • @hul8376
      @hul8376 3 года назад +2

      @@Haryad-nh5kc its good to ask questions, programming is not easy to understand when you dont see the logic behind the code.

    • @manchesterunited9576
      @manchesterunited9576 2 года назад

      @@mikeb3717 Return basically tells the computer that the function is over. Print doesn't.

  • @lecimbrohan1672
    @lecimbrohan1672 2 года назад

    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

  • @rscott9994
    @rscott9994 10 месяцев назад

    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)?

  • @r0me09696
    @r0me09696 2 года назад

    Thanks fellow Bro!

  • @ahmetunaldi7601
    @ahmetunaldi7601 2 месяца назад

    Bro is great

  • @rossterry3002
    @rossterry3002 3 года назад

    Awesome man thanks

  • @Redypanda
    @Redypanda Год назад

    helpful thank you :)

  • @Dm__0612
    @Dm__0612 2 года назад

    Thank you ❤️

  • @simomonti8986
    @simomonti8986 3 года назад +2

    thank u bro

  • @programram-hg5ht
    @programram-hg5ht Год назад

    thank you bro code !!

  • @pranshusinha7266
    @pranshusinha7266 2 года назад

    Thanks bro!

  • @kemann3815
    @kemann3815 2 года назад

    This channel is so good i just can't not return here

  • @b-45-nishantkambli48
    @b-45-nishantkambli48 8 месяцев назад

    love u my bro

  • @unapiedra3827
    @unapiedra3827 Год назад

    useful

  • @MarjorieRoseMasilang
    @MarjorieRoseMasilang 7 месяцев назад

    Thanks Bro!!

  • @aarontabuchi5693
    @aarontabuchi5693 2 года назад +3

    I’m sorry, can I ask who’s calling? Lol in other words who is “the caller” in this example?

    • @nehemiechery4947
      @nehemiechery4947 2 года назад +1

      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.

    • @mozah3alman234
      @mozah3alman234 Год назад +1

      in order for a function to execute its code it has to be called .
      example:
      def caller():
      print("Lily berry")
      caller()

  • @bismarana1589
    @bismarana1589 Год назад

    6 times 8 is really great 6 times 8 is forty 8. that got me

  • @AyaElgosrani
    @AyaElgosrani 10 дней назад

    besttt

  • @escobol
    @escobol Год назад

    thank you!

  • @Coding_Fun22
    @Coding_Fun22 Год назад

    cool!

  • @athiyakhan526
    @athiyakhan526 Год назад +1

    ooo-waaa