Hello YouTubers, I'm Parvez and this is our 16th video in Python 3 Programming Basics
and our second video in Python Object Oriented Programming Concepts. In the previous video we have learned about how you can create classes and objects in
Python 3. In this video we are going to continue our object oriented topics and we are going to
learn about Python Initializer Method. So in some other programming languages like C++ or Java we have Constructor and this initializer
method is the similar concept of Constructor. So by using this initializer method, this method is called when an object is created
from the class and this method allows the class to initialize the attributes of the class
So now I'm going to open my PyCharm IDE and I'm going to show you the practical example
of creating initializer method in Python language. So now this is my PyCharm IDE and this is from the previous video that we have created
classes and objects. Now I'm going to create a new Python file and I call it initializer method
So also you can call it Constructor. Now let me create a new class, so class car
Now creating initializer method you can give diff and init. This is a reserved word in Python programming language
Now in here I can give for example model, also color and also speed
Now after this you can simply write self.model is model and self.color is color and self.speed
is speed. Now we have created our class and also we have created our initializer method
Let me create some more behaviors. So diff start and let me print self.model is started and let me create another method
diff stop and print self.model is stopped and let me create another method in here
diff accelerate. So now we can print self.model is accelerating
Now let me create some object for my disk class and so let me create a Suzuki underscore
car and car. Let me give for example Suzuki and the color is red and the speed is 80
For example you can give it. And let me create another object for example Ferrari car and car
So Ferrari and let me give the color for example black and also the speed to 40
Now we have created two objects. Now you can call these methods that you have created
So for Suzuki let me Suzuki car dot start and now if I run my disk code you can see
that Suzuki is started. And if I write for example Ferrari car dot start and now if I run it you can see that
Ferrari is started. And if I say for example Ferrari dot stop and if I run this you can see Ferrari is stopped
and also Suzuki car dot accelerate and now if I run it Suzuki is accelerating and Ferrari
dot accelerate and I receive Ferrari is accelerating. So thank you guys
If you have any question please let me know and for the further videos please subscribe to my channel