Loading lesson path
Python
Classes, objects, constructors, inheritance, and the patterns that make Python code reusable.
Python OOP
Python Classes/Objects Python is an object oriented programming language. Almost everything in Python is an object, with its properties and methods. A Class is like an object constructor, or a "bluep…
Challenge: Classes/Objects Test your understanding of Python classes by completing a small coding challenge.
The __init__() Method All classes have a built-in method called __init__(), which is always executed when the class is being initiated. The __init__() method is used to assign values to object proper…
Challenge: __init__ Method Test your understanding of creating classes, __init__, properties, methods, and objects.
The self Parameter The self parameter is a reference to the current instance of the class. It is used to access properties and methods that belong to the class. Example Use self to access class prope…
Challenge: self Parameter Test your understanding of the self parameter by completing a small coding challenge.
Class Properties Properties are variables that belong to a class. They store data for each object created from the class. Example Create a class with properties: class Person: def __init__(self, name…
Challenge: Class Properties Test your understanding of class properties by completing a small coding challenge.
Class Methods Methods are functions that belong to a class. They define the behavior of objects created from the class. Example Create a method in a class: class Person: def __init__(self, name): sel…
Challenge: Class Methods Test your understanding of class methods by completing a small coding challenge.
Python Inheritance Inheritance allows us to define a class that inherits all the methods and properties from another class. Parent class is the class being inherited from, also called base class. Chi…
Challenge: Inheritance Test your understanding of Python inheritance by completing a small coding challenge.
The word "polymorphism" means "many forms", and in programming it refers to methods/functions/operators with the same name that can be executed on many objects or classes. Function Polymorphism An ex…
Challenge: Polymorphism Test your understanding of Python polymorphism by completing a small coding challenge.
Python Encapsulation Encapsulation is about protecting data inside a class. It means keeping data (properties) and methods together in a class, while controlling how the data can be accessed from out…
Challenge: Encapsulation Test your understanding of Python encapsulation by completing a small coding challenge.
Python Inner Classes An inner class is a class defined inside another class. The inner class can access the properties and methods of the outer class. Inner classes are useful for grouping classes th…