In-depth Understanding of Classes and Object in OOPs with Python

Basic concepts for modular programming

Amit Chauhan
6 min readJul 16, 2023
Photo by ThisisEngineering RAEng on Unsplash

In this article, we will discuss object-oriented programming concepts. When we are working on a massive project it is important to make a code more sustainable and efficient. By making small modules of code, the programming becomes more readable and easy to interpret.

Topics to be covered

  1. Objects
  2. Class
  3. Encapsulation


What is an object?

  • An object always refers to the class. In python almost everything is an object, whenever we define a variable in actual we are creating an object that is related to some class in python.
  • The data type is a class and when we define a variable it becomes the object of that class.


Suppose creating a variable with different data types.

# variable types (these are normally object literal by built-in classes 
# available in python)

int_var = 5
str_var = “six”
list_var = [1,2,3,4,5]

# Let's see the type of these variables

print("Type of integer variable: ", type(int_var))
print("Type of string variable: ", type(str_var))
print("Type of list variable…