![]() It aims to implement real-world entities like inheritance, polymorphisms, encapsulation, etc. I will explain about reading JSON in python topic in my next article.In Python, object-oriented Programming (OOPs) is a programming paradigm that uses objects and classes in programming. In this article, I have explained about OOPs concepts in python. The efficiency of the programmer increases. With the help of the data abstraction concept, the data is secure and safe.Ĭlasses can be shared, we can reuse the code. In python, we define a private attribute with the help of underscore as a prefix.īy using OOPs concepts in python, we can achieve the following: Data and programs are covered together in one unit, in Encapsulation so that it can’t be modified by chance. By using the Encapsulation concept, access to variables and methods can be restricted. Generally, Encapsulation and Data abstraction are used as a synonym because data abstraction is done, with the help of encapsulation.Įncapsulation is an important concept in OOP. Abstracting means giving names, to things so that the name contains the details of the function or program. Generally, animals don’t speak but some certain animals like, cats and dogs have a strong application.īy using the Abstraction concept, we can hide inner data and can show only activities. In this example, the behavior, speaking is polymorphic and it is based on animals. ![]() By the name, we can say by using Polymorphism concept, we can perform one task in many ways.įor instance, if you have an animal class, and every animal speak. Poly indicates many and morphs indicate shapes or forms. The class that we created is known as, child class or derived class whereas, the class whose properties are being used is known as, Parent class or base class. With the help of the Inheritance concept, we can create a class that can use all the behavior and properties, of some other class. ![]() The inheritance concept can be used to reuse the code. This means that the child objects use, all the behaviors and properties of the parent object. Inheritance is the major concept of OOP that uses the real-time inheritance concept. Methods are used to define, the function or behavior of an object. ![]() The method is a function of an object, which is defined inside a class. When you complete filling the form, your form is an example of the class and it has real data of you. like a cat named kitty whose age is 6 years.Ī class is similar to a form, which specifies the required data. The object can be any real-time substance like a car, pen, etc. The object is a substance that has behavior or functions and state. In the animal() class, the age and name are required to define an animal, but it will not mention a certain animal’s age or name.Īn Object is a duplicate of the class, with real values. Take the animal example, to record the properties of an animal like the age and name, we create a class animal().Ĭlass is the plan for defining anything, but it doesn’t show us any real matter. If you used a list or an array, the first component can be the name of the animal, and the second component may be its age.īut from this, how can we know which component is meant to be what? If you have 200 various animals? Are you sure every animal has both, age and name? To these animals, if you want to add other properties? For this, the Organization of data is a drawback, so we use classes.Ĭlass is used to make a data structure, defined by users that has some information about something. To get in-depth knowledge on Python You can enroll for free live demo Python Online Courseįor instance, if you want to find a number of different animals. Object-Oriented Programming concepts include concepts of class, object, method, inheritance, polymorphism, data abstraction, and encapsulation. OOP represents real-time things as software objects, that have data related to them and can do specific functions. Object-Oriented Programming is a way of creating strong, real-time things like cars and connected things, like teachers and students, etc. Object-Oriented Programming in Python is a programming model, which gives structured programs so that behaviors and properties, are tied together into single objects. Python develops applications, with the help of Object-Oriented Programming concepts(OOPs).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |