Learn practical skills, build real-world projects, and advance your career

Classes and Object Oriented Programming in Python

This tutorial is a part of the Zero to Data Science Bootcamp by Jovian

alt

Object-oriented programming (OOP) is a method of structuring programs into objects that encapsulate data and functionality. For examples, Numpy arrays and Pandas data frames are objects that contain data and offer methods to retrieve, manipulate and perform operations on the data stored within them.

Python is an object oriented language, everything in Python is an object. Every object in Python is an instance of a class. Classes are blueprints for creating objects. In this tutorial, we'll explore how to create new classes and objects in Python.

This tutorial covers the following topics:

  • Defining classes and creating objects
  • Class constructor, properties and methods
  • Implementing "dunder" methods for easier usage
  • Getters, setters, static methods & class methods
  • Inheritance, overriding and abstract methods

How to Run the Code

The best way to learn the material is to execute the code and experiment with it yourself. This tutorial is an executable Jupyter notebook. You can run this tutorial and experiment with the code examples in a couple of ways: using free online resources (recommended) or on your computer.

Option 1: Running using free online resources (1-click, recommended)

The easiest way to start executing the code is to click the Run button at the top of this page and select Run on Binder. You can also select "Run on Colab" or "Run on Kaggle", but you'll need to create an account on Google Colab or Kaggle to use these platforms.

Option 2: Running on your computer locally

To run the code on your computer locally, you'll need to set up Python, download the notebook and install the required libraries. We recommend using the Conda distribution of Python. Click the Run button at the top of this page, select the Run Locally option, and follow the instructions.

 
!pip install jovian --upgrade --quiet