Python reduce ♻️

Поделиться
HTML-код
  • Опубликовано: 10 сен 2024
  • Python reduce function tutorial example explained
    #python #reduce #function
    reduce() = apply a function to an iterable and reduce it to a single cumulative value.
    performs function on first two elements and repeats process until 1 value remains
    # reduce(function, iterable)
    import functools
    letters = ["H","E","L","L","O"]
    word = functools.reduce(lambda x, y,:x + y,letters)
    print(word)
    factorial = [5,4,3,2,1]
    result = functools.reduce(lambda x, y,:x * y,factorial)
    print(result)
    Bro Code merch store 👟 :
    ===========================================================
    teespring.com/...
    ===========================================================

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

  • @BroCodez
    @BroCodez  3 года назад +13

    # reduce() = apply a function to an iterable and reduce it to a single cumulative value.
    # performs function on first two elements and repeats process until 1 value remains
    #
    # reduce(function, iterable)
    import functools
    letters = ["H","E","L","L","O"]
    word = functools.reduce(lambda x, y,:x + y,letters)
    print(word)
    # factorial = [5,4,3,2,1]
    # result = functools.reduce(lambda x, y,:x * y,factorial)
    # print(result)

  • @clear1948
    @clear1948 2 года назад +18

    Man, you explained it so simply. I spent a whole week trying to understand what it does until I found this video. Thank you so much, bro ❤👊

  • @erwinalfarero8020
    @erwinalfarero8020 3 года назад +7

    Hello sir, thanks for this kind of content it really helps specially we are now in online class. Im newly subscriber of you're youtube channel Godbls and more power ❤🙏
    From zambonga philippines🥰

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

      thanks Erwin! Hello from the USA!

  • @cristiucvladimir7909
    @cristiucvladimir7909 4 месяца назад +1

    This guy is awesome!

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

    🐐

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

    I know this is a big thing to ask but could you maybe create a video thats around 1 hour long explaining all the features of functool? (the things we would want to use would do too) You can get views with that video too i believe. :)

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

      not a bad idea!

  • @andriatsivafaharetanarakot2014

    To the point so easy to understand. Thank you.

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

    Thanks Bro, pretty sure I will be able to use reduce function at some point

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

    Wow now i can use one line of code to find factorial of a number

  • @quietcorner5989
    @quietcorner5989 11 месяцев назад

    Bro code you are my favorite mentor

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

    great as always !!

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

    Спасибо!

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

    excellent. you made it easy to understand

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

    VERY NICE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

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

    Simple and to the point

  • @user-xo4rr5en3e
    @user-xo4rr5en3e Год назад

    wow it's very helpful, Thanks bro

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

    Thanks bro, You saved me.

  • @rubenc4696
    @rubenc4696 4 месяца назад

    thanks

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

    thanks a lot , this was helpful

  • @Mike-vj8do
    @Mike-vj8do Год назад

    good video, thank you

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

    nice explanation, man! Thank you so much!

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

    Wow!

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

    meow~!

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

    Thank you!

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

    Cool story

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

    yo!

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

    yooooo

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

    Is there a way to reset the accumulator in the reduce function? for example when ur tryna get the sublist of a list

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

    I have some questions for this video. How does comma(,) work and what is its duty ? Can I remove it ?
    (lambda x, y--> ,

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

    good video

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

    You upload a lot of videos in a batch, why not one video per day or something like that?

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

      I was losing subscribers :(
      I think that people we're getting annoyed by the daily uploads if it wasn't their preferred language

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

      @@BroCodez but for the algorithm is it not better to have several videos in several days instead of several videos in one day?, that would make more people watch your channel and you could have more subscribers than you are losing or what you think?

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

      ​@@BroCodez u make good videos!
      Would love a video on proper architecture/layout of folders and files of an app

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

    MY Random comment ❤

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

    comment

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

    commenrt

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

    We can simply use join()

  • @user-xk7de1jw8g
    @user-xk7de1jw8g Год назад

    # Mad libs game
    adjective1 = input("Enter an adjective : ")
    noun = input("Enter a noun :")
    adjective2 = input("Enter another adjective : ")
    verb = input("Enter a verb :")
    adjective3 = input("Enter an adjective: ")
    print("---------------MAD LIB GAME IS------------")
    print(f"Today I went to a {adjective1} zoo.")
    print(f"In an exhibit I saw {noun}")
    print(f"{noun} was {adjective2} and {verb}ing")
    print(f"I was {adjective3}")
    Enter an adjective : suspicious
    Enter a noun :Mark Zuckerberg
    Enter another adjective : scary
    Enter a verb :meow
    Enter an adjective: amazed
    --------------- MAD LIB GAME IS ------------
    Today I went to a suspicious zoo.
    In an exhibit I saw Mark Zuckerberg
    Mark Zuckerberg was scary and meowing
    I was amazed

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

    reduce: "E","A","S","Y"

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

    Wow!