WEBVTT

00:00.000 --> 00:03.000
Polymorphism and Abstract Classes

00:03.000 --> 00:10.000
In this video, we will understand apply polymorphism with abstract classes in Python

00:10.000 --> 00:15.000
Use polymorphic functions for multiple object types

00:15.000 --> 00:19.000
Let's understand polymorphism

00:19.000 --> 00:25.000
Ever told a cat, a dog, a parrot, and even a tiger to speak

00:25.000 --> 00:30.000
And heard four different sounds means one command, many results

00:30.000 --> 00:32.000
That's called polymorphism

00:32.000 --> 00:37.000
And today, we'll also discover abstract classes

00:37.000 --> 00:41.000
Abstract class is a plan for animals

00:41.000 --> 00:44.000
It says every animal must have a method called speak

00:44.000 --> 00:47.000
But it doesn't say what sound to make

00:47.000 --> 00:50.000
The cat follows the abstract class and says

00:50.000 --> 00:52.000
I'll make a meow sound

00:52.000 --> 00:55.000
The dog class also follows the plan but says

00:55.000 --> 00:59.000
I'll make a woof sound, same method follows parrot and tiger

00:59.000 --> 01:02.000
Here's the code in action

01:03.000 --> 01:06.000
Dog and cat both have a speak method

01:06.000 --> 01:09.000
Dog says woof, cat says meow

01:09.000 --> 01:12.000
Same method name but different results

01:12.000 --> 01:15.000
That's polymorphism

01:15.000 --> 01:17.000
Abstract class

01:17.000 --> 01:20.000
Animal is an abstract class with a rule

01:20.000 --> 01:23.000
Every child must define speak

01:23.000 --> 01:26.000
Dog and cat follow the rule and give their own sound

01:26.000 --> 01:32.000
This ensures structure while still allowing different behavior

