Classes and OOP

An introduction to object-oriented programming

Object Oriented Programming

Python is an object-oriented programming language. This means that almost all the code is executed using a special construct called ‘classes’. Programmers use classes to keep related things together.

Classes act as blueprints to create objects. An object is simply a collection of variables (data) and functions that act on those variables. Objects make representing real-world scenarios much easier.

Let’s consider the concept with references to cars. For a particular car, the class would be the blueprint, so, a car.

Then, the object would represent each individual car produced based off of that blueprint. Each car has different characteristics, which act as the variables/attributes of the object, and can perform actions like driving and stopping, which represent the functions/methods of the object.

It may seem like a confusing concept at first, but object-oriented programming is becoming the norm and several modern programming languages (including modern Java, C++, and Python) are based on objects, rather than procedures or functions, like the past. So, it is becoming increasingly important that you understand the basic concept.