 Hello everyone. Welcome to Python Tutorials by Walchand Institute of Technology. Myself, Samprit Patel, Assistant Professor, Department of Computer Science and Engineering, Walchand Institute of Technology, Sholapur. Today, we are going to see about object-oriented programming using Python. At the end of this video, students will be able to understand the principles of object-oriented programming language. So, let's start about what is object-oriented programming language. Now, Python is a multi-paradigm programming language. It's supposed different programming approaches. So, the programming approaches that are widely used are procedural-oriented programming and object-oriented programming. The one we are going to go through in today's video. One of the popular approaches to solve programming problems is by creating objects. And this itself is known as object-oriented programming. The concept of object-oriented programming in Python focuses on creating the code which is reusable. This concept is also known as don't repeat yourself, that is, DRY. So, these are some principles of object-oriented programming class, object, inheritance, polymorphism, data abstraction and data encapsulation. Together, these form a pillar of object-oriented programming. Now, we'll go through these principles one by one. The first principle is class. A class is a user-defined blueprint or we can say a prototype from which objects are created. So, it represents a set of properties or attributes which we usually call and methods that are common to all objects of the same type. For example, if you have a student class, then it should contain an attribute and methods such as the attributes may be name, roll number, the year he is studying in and the marks. Whereas the methods can be percentage to be calculated from the given marks and to display the details of the student. Together, this form a class. The second principle is object. An object or what we can say is instance is an instantiation of a class. So, just writing a class is not enough. To access the attributes and methods of the class, we need to create an object. The object is an entity that has a state or a behavior and it may be any real world object like a mouse, a keyboard, a chair, table, pen, etc. So, an object consists of three basic things. First is the state. Second is behavior and third is its identity. The state it represented by attribute of the object. It also reflects the properties of an object. The second is behavior. The behavior is represented by methods of an object. It also reflects the response of an object with other objects. And the third is an identity. Each object has a unique name and enables one object to interact with other objects separately. So, this creates a uniqueness of each object of the class. The next principle is inheritance. Inheritance is one of the most important aspects of object oriented programming which simulates a real world concept of inheritance. Inheritance is a way of creating a new class for using details of an existing class without modifying it. By using inheritance, we can create a class which uses all the properties and behavior of another class. The new class is also known as derived class or the child class. And the one whose properties are inherited are known as the base class or a parent class. Some important terminologies related to inheritance are superclass, subclass and reusability. Superclass are the classes whose features are inherited which are also known as base class and parent class. Subclass is a class that inherits other classes which are also known as derived class, extended class or a child class. The subclass can add its own fields and methods in addition to what the superclass field and method has given us. The third terminology is reusability. Inheritance supports the concept of reusability. So, when we want to create a new class and there is some code already existing in a class that includes some of the code that we want, we can derive that code in the new class from the existing class. By doing this, we avoid writing the same code again in the new class and we are reusing the fields and methods of the existing class. The next principle is polymorphism. Polymorphism contains basically two words, poly and morphis. So, poly means many and morphis means shapes, so taking many shapes. By polymorphism, we understand that one task can be performed in different ways. So, polymorphism is an ability of object-oriented programming to use a common interface for multiple forms or data types. Let's take an example. We need to color a shape and there may be multiple shape options like square, triangle, circle, hexagon and so on. However, we could use the same method to color any shape. So, here we are not writing different methods for different shapes to be colored. We are using a single method to color any different type of shapes. So, this concept is basically called polymorphism. The next principle is data encapsulation. Encapsulation is one of the very essential aspects of object-oriented programming. It is used to restrict the access of methods and variables. So, in encapsulation, code and data are wrapped together within a single unit from being modified by accident. So, this wrapping up of data is nothing but a class. So, we have seen class is formed by a combination of properties or attributes and methods. So, this is nothing but the code and data which is wrapped together in a single unit. Encapsulation is defined as wrapping of data under a single unit. So, it is a mechanism to bind together code and data that it manipulates. Another way to think of an encapsulation is it is a protective shield to prevent the data of being accessed from by the code outside that shield. That is from outside the class. So, here it also provides a protection to a data so that it cannot be accessed outside the class. So, technically, in encapsulation, a variable or a data of a class is hidden from any other class and can be accessed only through the member functions of its own class in which they are declared. As in encapsulation, the data in the class is hidden from other classes. So, it is also known as data hiding. Encapsulation is achieved by declaring the variables in the class as private and writing the methods as public in the class to set and get the values of the variables. The last principle is data abstraction. Data abstraction and encapsulation both are often used as synonyms. Both are nearly synonyms because data abstraction cannot be achieved without encapsulation. So, it is achieved through encapsulation. Data abstraction is a property by virtue of which only the essential details are displayed to the user. So, the non-essential units are not displayed to the user which are not required. Just take an example of a car. So, a car is viewed as a car rather than any individual components it has. So, data abstraction may be also defined as a process of identifying only the required characteristics of an object, ignoring an irrelevant details. Consider a real-life example of a man driving a car. The man only knows that pressing an accelerator will increase the speed and applying brake will stop the car. But he does not know how on pressing the accelerator the speed is actually increasing. Or he does not know the mechanism of the car or the implementation of accelerator, brake, etc. This is what abstraction is. Taking a minute try to answer the question what are the differences between object oriented programming and procedural oriented programming. So, object oriented programming is a problem solving approach and is used where computation is done using objects. Procedure programming uses a list of instructions to do computations step by step. To make the development and maintenance of the code easier, in procedural programming it is not easy to maintain the code when the project becomes large or lengthy. It simulates the real world entity so real world problems can be solved through ops. It does not simulate any real world entity. It works on step by step instructions or approach divided into small parts of called function. It provides data hiding so it is more secure than procedural language. You cannot access private data from anywhere outside the object. Procedural language does not provide any proper way for data binding so it is less secure. The best examples of object oriented programming are C++, Java, .NET, C sharp, etc. And the examples for procedural language are C, FORTRON, Pascal, VB, etc. So, the key points of this video are object oriented programming may program easy to understand and as well as efficient. Since the classes are shareable the code can be reused. Data is safe and secure with data abstraction. Polymorphism allows the same interface for different objects so programs can be written in efficient coding. These are some references I have used to create this video. Programming in Python 3 of PSN Publications and core Python programming of DreamTech Press. Thank you.