Python Dunder Methods and Polymorphism
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.
Python Playlist:
https://youtube.com/playlist?list=PLnKe36F30Y4bcRomKi02sP9NR27KnBqCK
Github: https://github.com/ImKennyYip/python-data-structures-algorithms
Subscribe for more coding tutorials 😄!
Other Videos By Kenny Yip Coding
2021-05-02 | C++ Logic Operator |
2021-05-02 | Increment and Decrement in C++ |
2021-05-01 | C++ Type Casting |
2021-05-01 | Arithmetic Operators in C++ |
2021-05-01 | C++ Multiple Variables in One Line |
2021-04-30 | C++ Type Conversion |
2021-04-30 | How to check variable type in C++ |
2021-04-29 | Variables and Data Types in C++ |
2021-04-26 | Intro to C++ Programming |
2021-04-26 | Python Operator Overloading |
2021-04-24 | Python Dunder Methods and Polymorphism |
2021-04-24 | Python OOP Vending Machine |
2021-04-23 | Python Object Oriented Programming |
2021-04-23 | Python Classes, Methods, and Objects |
2021-04-22 | Generator Functions in Python |
2021-04-22 | Ternary Operator and List Comprehension in Python |
2021-04-22 | Python Ternary Operator |
2021-04-20 | List Comprehension Python |
2021-04-20 | Python List Comprehension |
2021-04-19 | List Slice in Python Memory |
2021-04-15 | Multiply List in Python |