OOPs or object oriented programming name itself says its object oriented, in this we are dealing with the different objects. Objects might have data for example.

shopping Items or Objects may have code to manipulate the data.

for ex:

x = 28

If I print type(x) it will give me class <int>.

int is a built in data type which mentioned in class int, and x is an instance of class int.

If I change and get type(“Hello World”) it will print class<str> here Hello world is a string data type which belong to str class here str stands for string.

Here one more concept come into picture which is class.


What is Class in OOPs?

 Class is nothing but a blueprint of a data which we need to use in code. It will eliminate the need of rewrite of a code. Its a great way to achieve DRY.

DRY stands for Don't Repeat Yourself. The name of class always start with Capital letter as I mentioned in syntax.




You can create a class to store the data of different books such as Author, Price, Place in library, number of copies available etc. Here I created class People I want to store data of people such as their Names, Occupation, Income, Age.

To store and get this data we need to give this while instantiating. Assigning class with a variable and store class details as and data this process known as instantiation.


The above code will give the income of Prashant and Vishal. but one sec Do i need to assign all variable one by one for every new object? The answer is NO.

To avoid this repeating of variable assign process we use __init__(self) function also known as constructor. these variables known as object variables.

Self keyword in constructor or in Function always address the object that we are invoking method. if we invoking data for person_1 object then in constructor self means person_1.


This code also give the same result as previous one, the income of Prashant and Vishal.

We need to create a function to manipulate the data in objects. If a function works on object known as method. Defining of a function inside class is same as defining function in code using def keyword.

To store the data we use setters and to get data we use getters, these also known as accessor and imitators.
ex: If i need to update the technologies on which Prashant and Vishal works in their firm then 


Here set_tech(self,technology) used to set technology, you can give list as a input.To get the data use get_tech() method. I will get below output
for person_1
Prashant works on Dev-Ops.

For person_2:
Vishal works on ['Java', 'Python', 'SCM'].


Pillars of Object Oriented Programming(OOPs):

There are four Pillars of OOPs 

Encapsulation: Encapsulation is the bundling of data and methods into a single unit called a class. It allows for the hiding of internal details and provides a way to control access to the data. Encapsulation promotes the principle of data hiding and information hiding.

Inheritance: Inheritance is a mechanism that allows a class (subclass) to inherit properties and behaviors from another class (superclass). It enables code reuse and promotes the concept of hierarchical relationships between classes. The subclass can add or modify existing behavior without changing the original superclass.

Abstraction: Abstraction focuses on representing the essential features of an object while hiding unnecessary details. It allows you to create abstract classes or interfaces that define a common structure and behavior for a group of related objects. Abstraction helps in managing complexity and building modular programs.

Polymorphism: Polymorphism means "many forms." It refers to the ability of an object to take on multiple forms and exhibit different behaviors depending on the context. Polymorphism allows objects of different classes to be treated as objects of a common superclass. It enables code flexibility, extensibility, and method overriding.

Here I mentioned only the names of pillars will are whole new blog for these pillars, Soon