I have defined a class God which contains three attributes modern brand and in addition to these three
attributes I have also added two methods in this class.
When does the Start Engine method and the others excel at it.
Method methods add functions defined inside the body of a class and they used to define the behavior
of an object so methods are dependent on the state of the object.
And if you notice here we have used the def keyword d e f d e f key word to define a method inside the
class so you have a structure a blueprint ready.
Now you can use this blueprint to create objects of this type.
The procedure to create an object is similar to a function call.
Once you define a class we can create as many objects of this class as we like and the objects of a
class are called instances.
Detail on that is used for creating a new instance of a class in skull instantiating.
How do you define an object of a class or an instance of a class.
The procedure is similar to a function call.
So here you have the class name followed by parenthesis and this function call is assigned to the instance
of the object.
Say for example you call this object A B C so in order to keep track of the object we have assigned
this function card to a variable.
We can create as many instances of the class as we like.
So let's create another instance we will call this X Y Z.
And here we have the function called so each of these instances A B C and X Y Z.
Completely independent objects with their own properties and methods.
And each of these objects are instances can be manipulated independent of each other.
So this is of a class God in which we have defined two methods.
The first one is the undisclosed underscored in it underscored underscore.
So it also call double underscored in a method.
And the second method is the start engine Method Method that begin with double underscore I'd call special
functions as they have special meaning.
Here we have the inert metal the init method gets called automatically when a new object of the class
is instantiated the init method also known as a constructor is used to set the state of the objects
attributes.
So here I have defined a new object to IDB by calling the last name and I have custody arguments the
arguments that are passed to the class name given to it in it method and we will never have to call
the init method.
It gets called automatically when we create a new instance of a new object like other functions method
and init method can dig any number of arguments so we will not get into the body of the init method
so we have not understood that the argument that we passed to the last name given to the init method
in the definition of the init method we have four parameters.
The first one is the self parameter and then we have the model brand and ear and within the method body
we have today statement said Dot model equal to model self don't bland equal to Brand said data or equal
to.
Or does it self but amateur here mean and what are these three assignment statements.
It is a convention and Biden to name the first parameter of a meter as self and this parameter save
is a reference to the current instance of the class so self refers to the object that is being currently
created so in other class methods it refers to the instance whose method was called and descent.
But amateur lets us access all the instant variables for that specific instance.
So what does this assignment statement mean self dirt model.
Equal to modern
debatable self-taught model is an instance variable.
It is completely different from this variable model and this variable model is passed into the init
method as an argument.
So the model here refers to the parameter in the inert method and self doubt model is the instance variable.
So for example we have created the instant c v by passing arguments like the model and in the brand
and you put out understanding.
This means c v dot Morgan
is 0 0 1 and this argument has been parsed through the input method which gets called automatically
when we create an object similarly the second instance vegetable brand so which is C I'd be brand is
Honda.
Then we create another object say for example Corona the new object is Corona.
This assignment statement would be equal and to Corolla DOD modern is equal to 0 0 2 and then Corolla
Dot brand
is Toyota if we want to access instant vitamin within the class from any of these functions are any
of the methods we use.
This notation said that modern self DOD brand Soviet prefix the self but I'm a dead before the after
separated with the dot operator outside the glass definition if we want to access any all the instance
attribute we can access them using the the name of the object or the name of the instance.
So for example if we want to access the instance attribute model that gives you can access using the
object name of the instance name and then separating the attribute name with the intent name using a
dot operator outside the class definition you'll use the object of the instance name within the class
function you use the self but amateur so we have just seen how instance attributes can be called from
within the class definition and outside the class no let us see how we can call methods that are defined
in the class using the instances that are created.
So here to have defined an object crawler so outside the class definition if we want to call a midterm
this is how we do object dot method name.
So controller dot start engine and then bid entities.
So this is how we call it access methods in the class.
If you notice the method definition has a set of but amateur but indeed.
Method call.
We haven't parsed any parameters but it did work.
This is because whenever it an object cause it method the object itself is biased as the first argument.
So the first argument in this method call would be the object itself.
That is all followed by any argument that we bus in the method
but not
work.
Yep yep yep
yep yep.
More
adapted.
I think
that.
Ya ya ya ya ya ya ya ya ya ya.
Yep yep yep yep yep yep yep yep yep yep yep yep yep yep yep yep yep yep yep yep yep yep
yep
yep yep yep yep yep.
Donald.
Yeah.
Back to
ya ya ya ya ya ya ya ya ya ya ya
ya ya ya ya ya ya ya ya ya ya ya ya spectacle
ya
ah ah ah ah ah ah ah ah ah ah well
it's going to be a military
so da da da da da da da da da da da.
Yep yep yep yep yep yep yep yep yep yep yep yep
yep yep yep yep yep
Gotcha.
But forget about
ah ah ah
ah ah ah ah ah
ah ah ah ah ah ah ah
ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah
ah ah ah
ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah
ah ah ah ah ah that's
get me
ah
yeah
let me get back
like
typical
ya
ya ya ya ya ya ya ya ya ya ya
ya ya ya ya ya ya ya ya ya
ya
ya BUYING ME DON'T LET
ME GO
YO YO YO YO YO just to be able to
get.