RUVIDEO
Поделитесь видео 🙏

Inheritance/Polymorphism in Object Oriented Programming | Python for Beginners | Code with Kylie #1

📁 Обучение 👁️ 16 📅 02.12.2023

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

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Inheritance/Polymorphism in Object Oriented Programming | Python for Beginners | Code with Kylie #1», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.