Object Oriented Programming

👋 Hi there, I am Nirmal. I am a former software engineer with a keen interest in data science and analytics domains. Besides, I love to contribute to open source and help others to understand various tech stuffs.
Search for a command to run...

👋 Hi there, I am Nirmal. I am a former software engineer with a keen interest in data science and analytics domains. Besides, I love to contribute to open source and help others to understand various tech stuffs.
No comments yet. Be the first to comment.
This series will provides the core concepts of python programming starting from variables, data types, control flow, and functions to some problem solving.
In object-oriented programming, Python provides different types of methods to define the behavior of classes. Three commonly used methods are instance methods, class methods, and static methods. Such methods help us to create more organized and effic...
Bias in Machine Learning Bias refers to the simplifying assumptions made by a model to make the target function easier to learn. High bias can lead to underfitting Represents the error introduced by approximating a real-world problem Example: A li...
When it comes to developing software applications, choosing the appropriate architectural style is a critical decision. Among the popular options are microservices and monolithic architecture. By understanding the trade-offs, readers can make well-i...

In a world where information is everywhere, businesses have tons of data at their fingertips. This data is like a goldmine waiting to be used for smart decisions. That's where Big Data analytics and Data Science come in. They're like the experts who ...

Python is a powerful tool for data professionals, largely due to its extensive collection of open-source libraries and packages. In this blog, we'll explore the fundamentals of pandas, with a special focus on its core data structures: Series and Data...

NumPy is a powerful library for numerical computing in Python, offering robust support for large, multi-dimensional arrays and an extensive collection of mathematical functions. Creating Arrays To begin using NumPy, import the library and create arra...

Python, a popular programming language, offers a powerful feature called object-oriented programming (OOP).
This approach allows developers to organize their code in a way that makes it easier to understand and reuse.
Central to OOP in Python are classes, which act as blueprints for creating objects with shared characteristics and behaviors.
They are abstract and blueprint only. For example, Let's imagine a map of your house before you construct it is class.
One class can have many objects like we can make multiple houses with the help of the same map.
class Classname:
#your variables and functions
When the house is constructed from it then it is considered an object which exists and is real.
Similarly, various features of house such as color, furniture, number of rooms, etc are also objects.
object_name = Classname()
#creating class
class Number:
def sum(self):
return self.a + self.b
obj = Number()
obj.a = 10
obj.b = 10
s = obj.sum()#calling sum() with
print(s) # Object = 20
__init__())class Map:
#instance method because it is bound to instance of class
category = 'house_category'
def __init__(self, color, num_rooms, area):
#declaring instance variable
self.color = color
self.num_rooms = num_rooms
self.area = area
# Creating different objects for the House class
house1 = Map("Green", 10, 2500)#object1
house2 = Map("Orange", 2, 1000)#object3
print(house1.color) # Output = Green
print(house2.num_rooms) # Output = 2
__init__ method is the constructor in Python which is automatically called at the time of object creation.
__init__ is the instance method because it is bound to the instance of the class.
Various variable inside this method is instance variable because it is associated with the object(self)
category variable or attributes outside init consctuctor is class variable.
self parameter is automatically passed as the first argument whenever the method is called.
By convention, it is named self, although you can technically use any valid variable name in its place.
self is the object in python.
self parameter allows you to access and manipulate the instance's attributes and call other instance methods within the class. For instance, self.attribute_name or self.function_name()