Object Oriented Programming – Set 1:

In this article, we will learn about class, object, and members which is a part of OOPs in Python and we will use it for Data Science.

Now we will look at an example which creates a class with single method.

OOPS Python data science

In the above example, we can create a new class using the class statement and the class name. This is followed by an indent statement block that forms the body of the class.

Now let’s create an object or instance of the class by using the class name and a pair of parentheses.


  • It is mandatory to have an extra first parameter in the method definition. A value is not provided for this parameter, but when the method is called, Python provides the value.
  • If we are using a method that takes no arguments, still we have to have an argument. This is the self.

When we call a method of such object as myobject.method(arg1, arg2), this will get convert by Python to MyClass.method (myobject, arg1, arg2)

The __int__ method:

It is similar to constructors in C++ and Java. It runs as soon as an object of a class is instantiated. Helps us to do any kind of initialization we want to perform on the object.

Class and Instance Variable:

Variables for those values are assigned inside a constructor or method with self is known as instance variable. On the other hand, class variables are those for whom value is assigned in class.

oops python data science

Instance variables can be defined inside normal methods also.

Creation of an Empty Class:

Empty set can be created using pass statement.

If you want to learn more about OOPs in Python for Data Science in detail then you can also check this and this.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.