Search⌘ K

Implementing Methods in a Class

Explore how to implement instance methods within Python classes to manipulate and use class properties. Understand the role of self as a reference to the object, how to define method parameters and return values, and how Python handles method overloading through default arguments to create efficient, clean code.

In this lesson, we will learn about the interaction between properties and other objects. This is where methods come into play. There are three types of methods in Python:

  1. instance methods

  2. class methods

  3. static methods

We will be discussing instance methods in this lesson since they are used the most in Python OOP.

Note: We will be using the term methods for instance methods since they are most commonly used. Class methods and static methods will be named explicitly as they are.

The purpose of methods

Methods act as an interface between a program and the properties of a class in the program. ...