OBJECT ORIENTED PROGRAMMING
WHAT IS OBJECT-ORIENTED PROGRAMMING?
Object-Oriented Programming(OOP), is all about creating “objects”. An object is a group of interrelated variables and functions. These variables are often referred to as properties of the object and functions are referred to as the behavior of the objects. These objects provide a better and clear structure for the program.
For example, a car can be an object. If we consider the car as an object then its properties would be — its color, its model, its price, its brand, etc. And its behavior/function would be acceleration, slowing down, gear change.
PYTHON OOPs CONCEPT:-
In this section, we will deep dive into the basic concepts of OOP. We will cover the following topics-
- Class
- Object
- Inheritance
- Encapsulation
- Polymorphism
- Data Abstraction
1. What is a Class?
A straight forward answer to this question is- A class is a collection of objects. Unlike the primitive data structures, classes are data structures that the user defines. They make the code more manageable.
Get Parthpritam’s stories in your inbox
Join Medium for free to get updates from this writer.
2. WHAT IS OBJECTS?
When we define a class only the description or a blueprint of the object is created. There is no memory allocation until we create its object. The objector instance contains real data or information.
3. Inheritance in Python Class
Inheritance is the procedure in which one class inherits the attributes and methods of another class. The class whose properties and methods are inherited is known as Parent class. And the class that inherits the properties from the parent class is the Child class.
4. Encapsulation
Encapsulation, as I mentioned in the initial part of the article, is a way to ensure security. Basically, it hides the data from the access of outsiders. Such as if an organization wants to protect an object/information from unwanted access by clients or any unauthorized person then encapsulation is the way to ensure this.
5.Polymorphism
This is a Greek word. If we break the term Polymorphism, we get “poly”-many and “morph”-forms. So Polymorphism means having many forms. In OOP it refers to the functions having the same names but carrying different functionalities.
7. Data abstraction
We use Abstraction for hiding the internal details or implementations of a function and showing its functionalities only. This is similar to the way you know how to drive a car without knowing the background mechanism.






