Это видео недоступно.
Сожалеем об этом.

Python higher order functions 👑

Поделиться
HTML-код
  • Опубликовано: 10 янв 2021
  • Python higher order functions tutorial example explained
    #python #higher-order #functions
    Higher Order Function = a function that either:
    1. accepts a function as an argument
    or
    2. returns a function
    (In python, functions are also treated as objects)
    ---- 1. accepts a function as an argument ----
    def loud(text):
    return text.upper()
    def quiet(text):
    return text.lower()
    def hello(func):
    text = func("Hello")
    print(text)
    hello(loud)
    hello(quiet)
    ----------- 2. returns a function ------------
    #def divisor(x):
    #def dividend(y):
    #return y / x
    #return dividend
    #divide = divisor(2)
    #print(divide(10))
    Bro Code merch store 👟 :
    ===========================================================
    teespring.com/...
    ===========================================================
    music credits 🎼 :
    ===========================================================
    Up In My Jam (All Of A Sudden) by - Kubbi / kubbi
    Creative Commons - Attribution-ShareAlike 3.0 Unported- CC BY-SA 3.0
    Free Download / Stream: bit.ly/2JnDfCE
    Music promoted by Audio Library • Up In My Jam (All Of A...
    ===========================================================

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

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

    # Higher Order Function = a function that either:
    # 1. accepts a function as an argument
    # or
    # 2. returns a function
    # (In python, functions are also treated as objects)
    # ----- 1. accepts a function as an argument -----
    def loud(text):
    return text.upper()
    def quiet(text):
    return text.lower()
    def hello(func):
    text = func("Hello")
    print(text)
    hello(loud)
    hello(quiet)
    # ------------ 2. returns a function -------------
    #def divisor(x):
    #def dividend(y):
    #return y / x
    #return dividend
    #divide = divisor(2)
    #print(divide(10))

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

    Thanks a bunch for the vid. It was really well explained with the examples!

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

    Thank you, Nicely explained.
    Very cool outro video, love it too.

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

    Hello fellow coders I new and this was a very VIDEO helpful. oops returned Loud

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

    I would always be grateful. For the last two days I had been stuck with decorators in python. You answered my question. 🌹 Thanks again.
    1) Liked
    2) Commented
    3) Subscribed

  • @porshkabir2535
    @porshkabir2535 2 года назад +6

    NEED ASSISTANCE ASAP, FOR THE SECOND ONE....
    how does divide(10) take the value to dividend(y)

    • @onlyLewds
      @onlyLewds 2 года назад +14

      heya, i had this issue too, after thinking for abit, I think i got it, let me try to explain:
      after the line divide = divisor (2), x becomes 2 and it goes through the code, returning divident.
      so now the next line, divide(10) can be read as divident(10) because it returned divident, thus y=10, hope it helps!

    • @jean-paulmpindumukandila1251
      @jean-paulmpindumukandila1251 2 года назад +1

      @@onlyLewds Thanks

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

    Helped me out with returning HOF, btw your voice sounds like an almost perfect text to speech robot 🤣

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

    Splendid, spend hrs with gpt bbut didnt get it, here 5 mins. I like this crazy function itself traveling hiding behind innocent variable name. Will make code looks simple but cant be copy pasted

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

    superb explanation. Thnx bro

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

    Simple nice introduction.

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

    excellent free knowledge

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

    yo the second example caught me off guard

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

    Thanks

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

    Bro, please add English subtitles, because it's only Vietnam. Lol
    Thank you!
    You are the best

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

    Good content

  • @haurvatat2006
    @haurvatat2006 2 года назад +8

    i don't really understand the second example

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

      he used function assigned to variable..the divisor(x=2) function returns dividend function.
      and then he assigned this result to divide variable. now the dive variable is acting as the dividend function with argument of 10.hope i sound clear

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

      @@manuelvaal1257 ty that makes more sense.

    • @Digital-Light
      @Digital-Light 2 года назад

      @@manuelvaal1257 thank you i understand your explanation

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

    I cannot wrap my head around the first one. The second one makes more sense if you write it like this:
    print(divisor(2)(10))

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

      Very good!

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

      wow thanks bro. I tried so hard to understand the logical of the 2nd one. but when I see your tips, it helps me a lot

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

    Well explained. Thank you!

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

    Good video

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

    Thank You Sir

  • @Franco-ss4bu
    @Franco-ss4bu Год назад +1

    kinda mind boggling

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

    Niceee man

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

    Good video bro

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

    Good stuff.

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

    Great stuff, very good tutorial.

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

    very useful, thanks

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

    Here is my random comment for your BRO ❤

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

    Thanks! I was srtuck on this

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

    thx 4 vid bro !

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

    Really useful

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

    Thank you!

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

    Thanks Bro

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

    thank you so much!

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

    Thank you

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

    Thanks!

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

    Wow!

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

    Why on the first example the function is called with the () and how can we differentiate from a variable (as it could be mistaken by an variable)

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

    thanks bro

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

    I don't get the efficacy of this in the context of making code readable, Making less code maybe.

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

    print(divisor(2)(10))

  • @HussainAli-sb1dv
    @HussainAli-sb1dv 9 месяцев назад

    love u

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

    Trippy stuff, but interesting

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

    Man, I thought it called closure, is not it? (the seconds examp)

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

    Does anyone has best playlist to learn react js

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

    random comment ;)

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

    higher order comment :P

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

    drop a comment

  • @MukeshKumar-tg6rv
    @MukeshKumar-tg6rv Год назад

    Sreen is not clear

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

    Thanks

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

    Thanks!

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

    Thank you

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

    Thank you bro