Search⌘ K

Classes and Methods

Explore the basics of Python classes and methods, including class creation, attributes, and the __init__ constructor. Understand how to define and use class methods to build object-oriented programs, a key skill for data science interviews.

We'll cover the following...

Like other programming languages, Python is an object-oriented programming language. Classes can be created using the class keyword.

Class creation

The class can be created using a class keyword. Let’s create a simple class with no functionality.

Python 3.5
class Car:
pass
porsche = Car()
print(porsche)

In the above code, we have created a class named Car. We have created an object, porsche which is the instance of the Car class.