 Hello everyone. Welcome to Python tutorials. Myself, Samprit Patel, assistant professor, department of computer science and engineering, Walshand Institute of Technology, Sholapur. Today, we are going to see about classes and objects in Python, that is, the concepts of object-oriented programming language. At the end of this video, you'll be able to write a Python script in an object-oriented programming style. So, before we go to the coding part, let's just see what are classes? So, we have already discussed in the previous video the basics of what are classes. So, a class is a virtual entity that can be seen as a blueprint or a prototype of an object. The class came into existence or comes into existence when it is instantiated. So, let's see a simple example. Suppose a class is a prototype of a building, a building containing all the details about floor, rooms, doors, windows, etc. We can make as many buildings as we want based on the details. Hence, the building can be seen as a class and we can create as many objects as we want of this particular class. So, let's see the syntax of how to create a class. In Python, class is created by using a keyword class followed by class name followed by class name and a colon. And in this, with an indentation, we'll have the block of code representing this particular class. So, let's consider an example of an employee whose attributes are id and name, that is employee id and employee name and with the help of a method, display will display the name and the id of this employee. So, we'll create a class employee which will have two id, two attributes. First is id say 101 and name abc. So, now we need a method to display the details. So, we'll create a function or method display and we will print, we will print the id and name. Okay. So, see here, we have used the keyword self which is a reference variable which refers to the current class object. So, this self will always refer to this particular current class and it will access the attributes of that particular class. It is always the first argument of the function. It is always the first argument of the function definition. However, using self is optional in a function call. Okay. When you call a function, this use of self keyword is optional. So, the self parameter refers to a current instance of a class and accesses the class variables. We can use anything instead of self, but it must be the first parameter of any function which belongs to that particular class. So, this is the way we have we are creating a class in Python. So, now what is an object? So, creating a class is not enough to access the attributes and methods of this class. What we require is an object which helps us to access this class. So, object is nothing but the instance of the class. The class needs to be instantiated if we want to use the class attributes in another class or a method. So, a class can be instantiated by calling the class by using its class name. So, let's see the syntax of creating an object. So, to create an object, first we need to have the name of the object is equals to class name and followed by round brackets. Okay. So, these round brackets may have an attributes or arguments if the class needs to be passed. Okay. If the arguments are needed to be passed. So, let's now create an object for the class we have created. Let's say the name of our object is EMP is equals to the name of the class employee followed by round brackets. Now, the object to this class is created. Now, we can access the method of this class that is display using the object. So, to access the method we have object name dot method name. Okay. So, once we have called this method with the help of this object, let's see the run the code and this will display the ID and the name of our employee. So, pause the video and try to write a Python script for the given problem statement. Here, we have to take a class vehicle which has four attributes name, kind of car, color of the car and value. We have to create two new cars, car one and car two respectively, where car one is a red convertible worth rupees 60 lakhs with the name BMW and car two is a blue SUV named Harrier worth rupees 20 lakhs. So, let's see a program. So, first we'll create a class class vehicle which will have four attributes. First is which will be a string value. Then we have the color of the car. Again, it will be a string value. Then we have a kind of car. So, we'll set this as a default value as a car and the value value is a floating point number just will give a default value of 100. Now, we need a function to display this. So, we'll take a function description. So, here we'll take an object of a string. So, d sc that is description string is equals to in brackets we'll have percent s that is name of class car is a red convertible worth rupees floating point. So, that is percent point two f. Now, we need to access these variables. So, to access we know self dot first is the name second is second is the color third is the kind of car and fourth is the value of the car the value of the car. Now, we need to return this. So, let's return d e sc underscore string dcs underscore string dcs underscore string. Now, we need to create an object of class car one is equals to vehicle and with the help of this object we'll assign the values to the attributes. So, car one dot name is equals to b m w car one dot color car one dot the value car one dot value is equals to 60 lakhs creating a second object for car two is equals to vehicle. So, I'll just copy this part and paste it I'll just change the name of the object here the name of the car is carrier which is of blue color and it is a suv type. Now, once you have given the values to the attribute what we need is to print the details. So, I'll say print accessing the method with an object description and similarly for the second vehicle car two dot description. So, let's run this program and see. So, yes b m w is a red convertible was 60 lakhs and here is a blue convertible with okay the value should have been 20 lakhs. So, let's change that. So, this is the output for the given problem statement. So, moving forward moving forward let's see how to delete an object. So, when you don't want a particular object to carry a storage space you can delete the object. So, we see in the previous example to delete the object we have a keyword del which will be followed by the object name. Okay. So, let's see let's see first we'll delete the attribute. So, I'll delete emp dot id okay and if I try to access now I'll delete the object itself delete emp. So, now if I try to access the method using emp. So, if I run this if I run this you'll get an error attribute error that employee instance has no attribute id. So, it will stop here itself here itself as it will not find any id id when you execute the display method. Okay. So, I hope this particular concept is clear. I've reused this references to create this video programming in python 3 of PSN publications and core python programming of dream tech press. Thank you.