Hello in this video we are going to look at a simple class example. What is a class classes are amazing classes allow you to encapsulate code and think of it like this. You have vehicles all over the world he left a game from them you have vehicles and you have a car that's a vehicle you have a motorbike that's a vehicle you have like a train that's a vehicle and the car has a speed, a motorbike, whatever speed, a train with the speed, counterweight, a motorbike, whatever weight, a train whatever weight, you see where I'm going here, they have similar properties. And they might have similar methods. One method might be accelerate, one more method might be D federate, no very similar sort of methods. And what we can do is create a class called vehicle for example.
And you'll have the properties I'm just create instances of the class and they each instance has its own unique set of values, but he shares common functionality, quality To take in. And if you don't get the first time go over the videos again, because honestly, it's the actual idea. The philosophy around classes is called object oriented programming. And it is one of the outside pitfalls that a lot of new developers fall into. So if you haven't come across object oriented programming, and you get a bit confused, don't worry, that is just natural. So in this video, simple example, the next video, we're going to look at creating instances of our class.
So to create a class, we simply have to use the keyword class. And then you specify the class name. So I want to say, a vehicle nastic vehicle class, in the, the example I always use when I'm teaching university as well. So now you can specify like any variables, so these will be global variables. So for this variable, I'm going to put speed for example, I'll set a default value of zero so by default, you know not not good. They can define as many methods as you want, I can put multiple variable as well, I'm gonna put one.
So we've already done methods, but the process is similar. So if I just say, play, I'm gonna say, increase speed, and I'm gonna pass in a parameter of increase amount. And something else to note is all methods in Python have to have DSL self keyword at the start, you won't actually pass anything in for the self keyword, this automatically passes in the instance of the class itself. So you will just pass in increase amount or those free variables including self data, passing the two variables, not the self. Okay, so put a colon in here. We are just going to say Got speed.
So this accessing the speed of this self. And we're going to say plus equals to increase amount. So we just add it to, we just add increase amount to speed. I think this is a very simple example. That's all there is to it. You can add more functions, you can add more variable that you can have a few other extra features that we'll cover throughout this series for that this is a very simple example.
In the next video, we're going to look at actually creating an instance of our class. And let's just run this just to make sure we're not getting any errors. Obviously, you won't display anything. We haven't done any prints. Last one. Thanks for watching, and I look forward to seeing you in the next Python class video.