Toptube Video Search Engine



Title:Inheritance/Polymorphism in Object Oriented Programming | Python for Beginners | Code with Kylie #10
Duration:12:50
Viewed:76,239
Published:21-09-2020
Source:Youtube

We are LEVELING UP our object oriented programming. Once you start creating objects in Python using classes, you can step up your OOP game by incorporating inheritance and polymorphism! Inheritance is when you can create child classes that inherit attributes and functions from the parent. These are often used when you have a more general overarching class but want to define more specific classes that may be similar but not quite the same. We do this in order to avoid copy-and-pasting a gazillion times. In this video, we use dogs as an example of how inheritance can be used. I demonstrate how to create a parent class (superclass) and child class (subclass), and initialize both of them. We can also have multiple inheritance, which is when a subclass can have multiple parents and inherits the unique functions and attributes of both of them. An example is a golden doodle! Polymorphism is related to inheritance. Polymorphism means taking many forms. In OOP, this is often related to subclasses that override the parent method so that the more specific class might follow a different set of instructions. In my example, I use different barks of different breeds of doggos. In practical terms, I've used this in past projects to account for the slight differences in the subclasses. For example, if we are calculating cost of an object, maybe one subclass is set in the US, and another class is specific to France.. we would use the subclass to change from dollars to euros in the France subclass and add an extra layer. We could do this with if-statements, but they might grow repetitive and confusing. Polymorphism is a cleaner way to implement something like this. Relevant links for more: https://thepythonguru.com/python-inheritance-and-polymorphism/ Inheritance vs polymorphism - https://www.geeksforgeeks.org/difference-between-inheritance-and-polymorphism Feel free to leave any questions. Please consider subscribing if you liked this video: https://www.youtube.com/c/ycubed?sub_confirmation=1 Thanks for watching everyone! ~~~~~~~~~~~~~~~~~~~~~~~~ Follow me on Instagram: https://www.instagram.com/kylieyying Follow me on Twitter: https://www.twitter.com/kylieyying Check out my website: https://www.kylieying.com



SHARE TO YOUR FRIENDS


Download Server 1


DOWNLOAD MP4

Download Server 2


DOWNLOAD MP4

Alternative Download :