#60 Python Tutorial for Beginners | Method Overloading and Method Overriding

Поділитися
Вставка
  • Опубліковано 2 жов 2024

КОМЕНТАРІ • 269

  • @varunkrishnaKyathanpally
    @varunkrishnaKyathanpally 5 років тому +132

    I will never forget about Method overriding in my life. Thank you:)

  • @giuseppepala8668
    @giuseppepala8668 5 років тому +186

    "My phone overrides my father's phone"
    Simply brilliant!

  • @tirthpatel7388
    @tirthpatel7388 4 роки тому +14

    The Way You Explain Every Concept With a Lovely Example Makes Learning Python So Easy. Thanks Navin Sir❤️❤️❤️.

  • @AudeJavel12
    @AudeJavel12 4 роки тому +2

    min 5:40 , def sum(self, a=None, b=None, c=None): , i use (self,a=0,b=0,c=0): , and then we dont need to use "if a != None" etc conditions. 3 lines of code instead of 6 =))

  • @inderkaur3012
    @inderkaur3012 2 роки тому +2

    Was unable to understand the concept of Method Overriding. But the way you taught this concept, was amazing. Great job!

  • @niveditaaaaaa
    @niveditaaaaaa Рік тому +2

    i would have NEVER understood this topic in my university. you made it so simple!!

  • @adityaroy6901
    @adityaroy6901 4 роки тому +3

    class Student:
    def sum(self, *b):
    c = 0
    for x in b:
    c += x
    return c
    s1 = Student()
    print(s1.sum(5, 6, 5, 4))
    can we use this for method overloading?

  • @janardan3210
    @janardan3210 4 роки тому +2

    The best example of method overriding.. I will remember it definately

  • @chiragukey7283
    @chiragukey7283 4 роки тому +2

    for method overloading using variable length method
    class student:
    def sum(self, a, *b):
    s = a
    for e in b:
    s = s+e
    return s
    s1 = student()
    print(s1.sum(4, 5, 6))

  • @mahendrashah9810
    @mahendrashah9810 4 роки тому +1

    what a explaining sir.....!
    who are dislike the
    Videos understanding very well and teaching is awesomeeee

  • @synthiapyre5618
    @synthiapyre5618 4 роки тому +15

    "I was not having a phone.", sounds so Shakespearean.

  • @LittleGroot
    @LittleGroot 5 років тому +1

    Sir you are the best your teaching skill is fantabulous keep it up.

  • @harsiddhisinghdev4650
    @harsiddhisinghdev4650 6 років тому +6

    Thanks sir please daily upload a video 🚴🚴

  • @shrishtigarg4674
    @shrishtigarg4674 Рік тому

    your teaching is best sir thank you for such content.😀

  • @sharathtenugolu5973
    @sharathtenugolu5973 4 роки тому +3

    Nice and easy explanation. Thank you so much. :)

  • @bhavikjinjala980
    @bhavikjinjala980 4 роки тому +1

    Very nice Explanation ✌️

  • @vishnukumarpaswan9053
    @vishnukumarpaswan9053 4 роки тому +9

    The eg.was just remarkable.
    The effort u put to make us understand is just insane.
    Salute to sir.

  • @narangparth
    @narangparth 4 роки тому +3

    As per me, the better option for method overloading would be:
    class A:
    def sum(self,*a):
    c=0
    for i in a:
    c=c+i
    return c
    a = A()
    print(a.sum(10,20,30,40))

  • @pavanjain2178
    @pavanjain2178 6 років тому +1

    Enjoying this session very much sir😊😊😊

  • @pawansoni4296
    @pawansoni4296 4 роки тому +1

    Dear Sir, Thank you for your efforts and teaching. I have very good learning by your videos. One query I have, In this video in OverLoading part, Where you have used example of NONE for a,b,c. I tried with '0' instead of None and it saved if,elif and else code and Results were same as you have shown.
    It this method with '0" will work fine, or this NONE can be used in diff scenario? Let me know your view point.

  • @preyaspatel3656
    @preyaspatel3656 5 років тому +1

    Sir, You are really great in teaching.... Thank you😊😊

  • @sumukhyr5954
    @sumukhyr5954 5 років тому +12

    Sir instead of assigning None to a , b , c variable in sum method , we can assign it to zero . So that we no need to check the None value of the arguments.

  • @pawnage3
    @pawnage3 3 роки тому

    Thank you Mr. Reddy! I really appreciate it.

  • @lokeshkatikireddi1924
    @lokeshkatikireddi1924 4 роки тому +5

    This guy has answer for any question. Awesome work Navin Reddy...

  • @abhishekabhi732
    @abhishekabhi732 4 роки тому +6

    sir very good example you had taken
    "i understand the concept perfectly now"
    thank u for this

  • @tonyreddy6897
    @tonyreddy6897 3 роки тому +3

    At 6:15 for method overloading, it would be better to pass 0 than None as we can skip that if condition.

    • @versatile7713
      @versatile7713 2 роки тому +1

      What if you pass strings as arguments

  • @gracevella9921
    @gracevella9921 3 роки тому

    Excellent use of example - easy to understand! Thank you

  • @sonofzues8414
    @sonofzues8414 5 років тому +5

    i Am watching your videos from years, just know your methods are simpler for beginners. and for everyone keep it up.

  • @PhoenixRisingFromAshes471
    @PhoenixRisingFromAshes471 6 років тому +5

    Sir your content is very very good .Although you take some time to post a video but the quality that we get is very good which compensates everything.Sir we can even wait for a year if the content is good so sir take some time and keep on posting such awesome videos on python because you are our only source of knowledge. :)

  • @mubarizmirzayev35
    @mubarizmirzayev35 4 роки тому +1

    Good video, but i would not write that func. like that def sum(self, a=None, b=None ... ) What if we have more than 4 variables. I would write that function like this:
    def sum(self, *args):
    s = 0
    for a in args:
    s += a
    return s
    Thanks again

  • @webcreationstudio7088
    @webcreationstudio7088 3 роки тому

    last exmaple was awesome

  • @amithsuryat1454
    @amithsuryat1454 2 роки тому +2

    Awesome class sir... brilliant teaching... I never forget about Method overriding in my life...
    🙏

  • @RohitSharma-cd5bs
    @RohitSharma-cd5bs 3 роки тому

    Op example sir, hats off to you sir ❤💕❤💕❤

  • @AyushSharma-be4kh
    @AyushSharma-be4kh 4 роки тому

    Definition of Perfect..!

  • @kisantimsinacoverz9744
    @kisantimsinacoverz9744 4 роки тому +9

    Hey Telesko! I love the way you give examples :-)I m 18 years old and I m learning python through your videos /////thank you very much for making this python series:-);-) I love you a lot for teaching me python

  • @akashsom178
    @akashsom178 3 роки тому

    Best explanation

  • @NitinJainNoida
    @NitinJainNoida 5 років тому

    No Need of if-else statement here, we can acheive this by simply using the ZERO.
    #method overloading
    class test:
    def add(self,a=0,b=0,c=0):
    s = a + b + c
    return s
    marks=test()
    print(marks.add(1,2))
    o/p: 3
    #insmot

  • @Dhananjoybhatta123
    @Dhananjoybhatta123 4 роки тому

    Awesome concept. Seriously sir, you teach in a great way. I will be looking for your next videos to understand the usage of this concept in depth.

  • @zakiasmaa6834
    @zakiasmaa6834 Місяць тому +1

    "My phone overrides my father's phone", Thank you for being such a wonderful teacher and for sharing your knowledge with the world. I'm looking forward to continuing to learn from you!

  • @ROHIT-gv7xk
    @ROHIT-gv7xk 5 років тому +6

    good explanation of method overriding

  • @dattukoralli1708
    @dattukoralli1708 4 роки тому +1

    instead of (self,a=None,b=None,c=None) we can (self,a=0,b=0,c=0) to avoide conditions

  • @prashanthmj4907
    @prashanthmj4907 4 роки тому +3

    Navin, this quick-learn course is awesome...I have been in the industry for 34+ years and decided to learn Python. I did not want to go to 3-6-9 month course and was looking for a quick overview. Excellent work. Keep it up. I have been programming since 1984 and have used almost all languages and platforms....OMG - there are so many things to remember to accomplish this smart programming using Python. I hope "Go" is not further difficult to learn....

  • @SaiKrishna-bd4yq
    @SaiKrishna-bd4yq 4 роки тому +1

    Hi Sir,
    In Method Overloading, instead of using None can we use zero.
    Is there any more memory usage of using zero?

  • @NewbieInForeignLand
    @NewbieInForeignLand 5 років тому +2

    Awesome videos sir 👌👌 & it's fun watching your videos while going to office daily. I never get bored & it's really very easy to recall all the concepts the way you explain them. Hats off to you. I loved the example you gave Nokia & Motorola 😃😄 Keep going sir 😄

  • @brosebg4012
    @brosebg4012 3 роки тому +1

    Overriding is same as MRO(Method Resolution Order), right??

  • @subhayanmajumder2756
    @subhayanmajumder2756 3 роки тому +2

    "Method Overriding " love u sir,u r god

  • @sourabhchoudhary7289
    @sourabhchoudhary7289 4 роки тому +1

    Nokia 1100😍
    We can use it as a weapon as well
    Ult battery

  • @dddeepakdhiman
    @dddeepakdhiman 4 роки тому +1

    Nicely Explained :) ...but I have a doubt here
    what is the difference between duck typing and method overriding

  • @rivalkido1162
    @rivalkido1162 3 роки тому +2

    6:07 you don't need that lengthy code just set default values of a, b, c as 0

  • @sasichandramorukurthi5868
    @sasichandramorukurthi5868 5 років тому +1

    we can put by default zero to sum method instead of none its working fine zero also

  • @sunnytawar7020
    @sunnytawar7020 4 роки тому +1

    Sir will you please make videos on data structure with python..

  • @RajeevKumar-wq3zm
    @RajeevKumar-wq3zm 6 років тому +1

    Sir, How can we use input function for fetch more than one values from keyboard in a single line...
    like in c we use
    scanf(" %d %d ", &a, &b);
    For Fetch two integer values From keyboard in a single line...
    how can we do it in python?????

    • @ROHIT-gv7xk
      @ROHIT-gv7xk 5 років тому

      a,b=int(input()) , int(input())

  • @ROHIT-gv7xk
    @ROHIT-gv7xk 4 роки тому +2

    Sir you said i make more videos on this topic interfaces , abstract classes sir please make videos on this topics

  • @akashanandh5633
    @akashanandh5633 3 роки тому +1

    We are learning python from you, where you learnt it from?

  • @lavasrani3887
    @lavasrani3887 4 роки тому +1

    Thank You sir for your amazing videos. But sir while method loading instead of using None in default parameter if we assign the value 0 to it we won't require the condition part that is if else part.

  • @Maks05N
    @Maks05N 4 роки тому +2

    you made me emotional i remembered my old days

  • @Laith.Alkhazragy
    @Laith.Alkhazragy 4 роки тому

    for the one how dont konw this method
    class student:
    def __init__(self,m1,m2):
    self.m1 = m1
    self.m2 = m2
    def sum(self,*a):
    return sum(a)
    s1 = student(58,69)
    print(s1.sum(5,6))

  • @harshnathjha1458
    @harshnathjha1458 2 роки тому +1

    Another day of thanking God for tutors like you who I owe my engineering degree to.

  • @khushichaudharysart275
    @khushichaudharysart275 6 років тому +2

    Sir please make a video series on different modules of Python

  • @umeshdangi123
    @umeshdangi123 2 роки тому

    hey i got this override symball on my pycharm ...how to remove that symball ....its created by pressing some random key on keyboard...i dont know how to remove it know .....its overriding methods in objects...may i face any problem due to this symball??

  • @DishandDestinationwithQuotes
    @DishandDestinationwithQuotes 4 роки тому

    kya baaat :) beautifully explained

  • @fireworks6795
    @fireworks6795 5 років тому +1

    it is a very good idea to have tutorial for practices, in which after watching tutorial of the concept we can learn better via practices. thank you

  • @anujdahiya341
    @anujdahiya341 5 років тому

    Method overriding also works in same class:
    class A:
    def add(self,a,b):
    return a + b
    def add(self,a,b,c):
    return a + b + c
    A1 = A()
    print(A1.add(10,20))
    --------------------this will give an error
    print(A1.add(10,20,30))--------------this will give 60-------
    first definition of add() takes self + two arguments but
    second definition of add takes self + 3 arguments.. so second definition overrides first definition of first add() method

  • @chandrashekhartigercharla1633
    @chandrashekhartigercharla1633 3 роки тому

    Class students:
    Def __init__(self,M1,m2):
    Self.m1 = M1
    Self.m2 = m2
    Def addin(Self,a=self.m1,b=2):
    Return a + b
    S1 = students (44,65)
    Print (S1.addin())
    I am getting S1 is not defined error.. please let me know how can we assign 44 value to a

  • @TheHitessh
    @TheHitessh 4 роки тому

    Cant we use *args or **kwargs instead?

  • @viny1819
    @viny1819 4 роки тому

    Write a python program using recursion to traverse every single element of the nested
    list.
    [10,20,15,[11,”hello”,25.5,[123,15,”hi”,[10,20],52],100,200],15,50,[51,”welcome”],1000
    ]
    sir please send me answer

  • @brightside1574
    @brightside1574 2 роки тому

    Simple trick
    class Miles:
    def sum(self,x= 0,y=0,z=0):
    sum=x+y+z
    print(sum)
    r1=Miles()
    r1.sum(1,3)
    class Miles:
    def mul(self,x= 1,y=1,z=1):
    mul=x*y*z
    print(mul)
    r1=Miles()
    r1.mul(1,3)

  • @soumyaketan9154
    @soumyaketan9154 3 роки тому

    class Meth():
    def __init__(self,aa,bb,cc):
    self.aa=aa
    self.bb=bb
    self.cc=cc
    def add(self,a=0,b=0,c=0):
    s=a+b+c
    return s
    gvn=Meth(3,4,5)
    print(gvn.add(10,20))
    simpul overloading

  • @bijenadhikari
    @bijenadhikari 4 роки тому +1

    i think i will not forget this overriding concept . thanks man.

  • @subhashisbiswal
    @subhashisbiswal 3 роки тому

    class Student:
    def sum(self,num1=0,num2=0,num3=0):
    print(num1+num2+num3)

    s1 = Student()
    s1.sum(5,8) # 13
    # can this be done for method overloading?

  • @irshadali9257
    @irshadali9257 5 років тому +1

    But exactly why python does not support overloading?

  • @Ashfak101
    @Ashfak101 2 роки тому

    while explaining the Method Overloading, if we set the values of a,b,c to 0 like a=0,b=0,c=0 then we don't have to do all the checks using if condition ? we can call even with a single arg and it would still work

  • @sagarrao79
    @sagarrao79 5 років тому

    we ca define sum like below also
    def sum(self,a=0,b=0,c=0):
    return a+b+c

  • @sampathkumar5699
    @sampathkumar5699 3 роки тому +1

    Overriding example is superb

  • @slonbeskonechen8310
    @slonbeskonechen8310 3 роки тому +1

    Great explanation! Thank you!

  • @binithsingh9274
    @binithsingh9274 3 роки тому

    Class S:
    def sum(self, a= 0, b= 0, c= 0):
    return a+b+c
    s1= S()
    print( s1.sum(2,3))
    #this is also working
    #please explain

  • @RahulKumar-zr5gu
    @RahulKumar-zr5gu 4 роки тому

    ohh,, me too till 10th I also don't had a mobile. but yeah you explained very well. your father's phone is urs and your phone overrides

  • @abdulrehanbasha1727
    @abdulrehanbasha1727 3 роки тому

    Why do we even need the below lines in method overloading example?
    def __init__(self):
    self.m1 = m1
    self.m2 = m2

  • @Daniel-om8wm
    @Daniel-om8wm 5 років тому +1

    Every one of your videos will have 100k views soon. You rock bro.

  • @amishapagare5845
    @amishapagare5845 3 роки тому

    why are we taking init method in method overloading ? what is the use?
    what is the use of line s1=student(58,65)

  • @KumarB819
    @KumarB819 3 роки тому

    Method overriding set backs when father have iPhone and I have normal phone....I would say iphone lol😂

  • @sreenivas6526
    @sreenivas6526 6 років тому +4

    Sir, can use **kargs in method overloading

    • @uselesscontent5998
      @uselesscontent5998 4 роки тому

      Yes

    • @nareshgopanaboina6644
      @nareshgopanaboina6644 4 роки тому

      **kargs for dictionary aruments like key value pair,, if you not sure how many args you are passing just use *args it takes as list ,,,args and kargs are just convention you and use any names but *, ** important to note

  • @GSEDITZAMV
    @GSEDITZAMV 9 місяців тому

    I just confused another vedio saying another ypu are saying this about method overloading i can't just u understand

  • @siddharthkumar533
    @siddharthkumar533 4 роки тому

    wooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooowwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww

  • @rakeshreddy1365
    @rakeshreddy1365 4 роки тому +1

    if python is a horse then u are riding over it....

  • @Dsuguna-s3v
    @Dsuguna-s3v 3 місяці тому

    I have a doubt in method over loading what is the use if using __init__methods and using m1 and m2 in the above video ???

  • @chejarlavineela3152
    @chejarlavineela3152 5 років тому +1

    Good explanation sir

  • @sayf8277
    @sayf8277 3 роки тому +1

    That father son example is just wow 🔥

  • @dragonwarrior7442
    @dragonwarrior7442 5 років тому

    class My class(str):
    pass
    print(Myclass("student"))
    O/p:--. student
    Same thing with int()
    After inherit STR we pass string value as a argument in MyClass constructoe but we didn't call any method of STR class
    without showing instance in a string format how it print student
    Can we create a class and inherit which will work like how STR work in MyClass:
    Please reply. Me I know you didn't have a time but I know you never let student doubt to go
    Yours UA-cam student

  • @narangparth
    @narangparth 4 роки тому

    Hi Navin,
    I work in NIIT Technologies and in my project, we don't use python.
    I've gone through your videos (till this point), and I'm making my notes as well.
    But I've noticed that I tend to forget what was taught in previous videos. So, have to jump back and forth.
    If python was used in our project, then, it would have helped me to practice.
    But for now, apart from the small assignments, I have nothing much to practice on.
    Can you please suggest what my next step should be? So, I keep on practicing.
    Regards,
    Parth Narang

  • @basavarajpatil9821
    @basavarajpatil9821 3 роки тому

    Insted of having none we can use default argument as 0 so ther will no use of using if statements.

  • @Swaapnilarts
    @Swaapnilarts 2 роки тому

    Can You explain>>>>When to use OverLoading And When OverRiding????????

  • @tech-learner4555
    @tech-learner4555 Рік тому

    When i want to use fn overloading with respect to data type, how will i achieve in python

  • @Perplexedsouvik
    @Perplexedsouvik 4 роки тому

    What if my father has a way better phone than me..I will go with the super class.

  • @sudiptamondal5182
    @sudiptamondal5182 Рік тому

    Sir I am from humanities background and currently working as a professional Interior Designer. I am 31years old and recently my partner suggested me to have a look into your videos when I told her I want to learn Python. I have no prior knowledge of coding or anything but after seeing and watching your videos I must say I am in love with the way you teach. If I can ever switch my career from being a designer to a developer of coder, I would thank you from the core of my heart. I am learning so much from you. Thank you once again.

  • @maedre9330
    @maedre9330 3 роки тому

    me wants to learn python - panik
    finds telusko - kalm
    he uses light mode - panik

  • @MrHmm-cv6gs
    @MrHmm-cv6gs 4 роки тому

    one more point what I have learner recently,
    dad can not use child 's phone.
    but revesre in not true

  • @sadhanalav4385
    @sadhanalav4385 Рік тому

    Yes default arguments will replace if any arguments missed at position..

  • @vinaymt6426
    @vinaymt6426 5 років тому +1

    Story to explain method overriding is superb❤️

  • @nishokkumar8738
    @nishokkumar8738 3 роки тому

    Instead of using none we can use zero? Which can make method smaller?