Python Classes Dunder Methods and Polymorphism

Subscribers:
50,600
Published on ● Video Link: https://www.youtube.com/watch?v=p5-D23sK_sU



Duration: 0:00
208 views
4


Python dunder functions and operator overloading by implementing the Complex Number class. Polymorphism means "different forms". So far we have created methods and dunder methods (operator overloading) as 2 ways of doing the same thing. For instance, we can create an add( ) method, or overload the _add_ operator.

We can apply the concept of polymorphism in our Complex Number class for function parameters. Here, we can add other Complex Number types or simple integers to our Complex Number. Unlike other programming languages, Python does not allow us to overload methods (define multiple functions with the same name). Instead since Python is dynamically typed, we can simply check the type of the value passed in to replicate this concept.

For more information on Complex Numbers:
https://www.mathsisfun.com/numbers/complex-numbers.html

Github: https://github.com/ImKennyYip/python-oop

Python Object Oriented Programming Playlist:
   • Python Object Oriented Programming  

Python Data Structures and Algorithms Playlist:
   • Python Data Structures and Algorithms  

Python Game Programming Projects Playlist:
   • Python Game Programming Tutorial  

Subscribe for more coding tutorials 😄 !