Object-Oriented Programming in Python
Write Python classes, reuse code through inheritance, and add equality, string output, custom exceptions and properties in this interactive course.
Object-oriented programming makes Python code easier to read, reuse and maintain by treating a program as a collection of interacting objects rather than a sequence of actions, with each object built from a class that acts as its blueprint. You write classes and constructors, reuse code by inheriting from other classes and redefining methods, make your objects compare, print and raise errors the way built-in types do, and control how their attributes are read and set.
What You Will Achieve
- Define a Python class from scratch and create objects with the starting values they need
- Build subclasses that reuse a parent class and redefine only the methods that need to change
- Make objects count as equal when they hold the same data, print readable descriptions and raise errors of their own type
- Guard internal data with attribute naming conventions and read-only properties
Program Overview
Classes, Attributes, and Constructors
Sets out what object-oriented programming is and how it differs from procedural programming, then has you write classes with their own data and methods.
- OOP terminology and object interfaces
- Attributes and methods in a class definition
- The __init__ constructor and its correct use
- Writing a class from scratch
Inheritance and Class-Level Data
Shows how classes inherit from one another and how data shared by a whole class differs from data stored on each instance.
- Instance-level versus class-level attributes
- Alternative constructors
- Subclasses, method inheritance and customized behavior
- Customizing a DataFrame through inheritance
Standard Python Behavior and Class Design
Makes custom classes act like standard Python data types, then closes with design practices for inheritance, polymorphic methods and controlled attribute access.
- Overloading equality and comparison operators
- String representations of objects
- Custom exceptions and exception hierarchies
- Private attributes, naming conventions and properties
Certificate Awarded (Paid)
Complete the course to earn it.
Job Outlook
Object-oriented Python is used in software engineering, web development, data science and game development, wherever programs are organized into reusable classes that other code can extend.
Good for: Python users who want to organize larger programs into classes and write their own subclasses, exceptions and properties.
Keep in mind: Despite the advanced label, the first chapter begins with what OOP is and a first class; the more advanced material sits in the inheritance and class design chapters.
Bottom line: It carries Python OOP past writing classes into making objects behave like built-in types and keeping their internal data guarded.
Frequently Asked Questions
Does the course use any Python data tools?
One inheritance exercise has you customize a DataFrame by subclassing it, which shows inheritance applied to a class you did not write yourself. Most other exercises center on classes you build, such as a square and rectangle example used to look at polymorphic methods.
How does the course handle attribute access?
The class design chapter takes up private attributes, attribute naming conventions and internal attributes, then moves on to properties. You create and set properties and write read-only ones as a way to control how an object's data is read and changed.
Which standard Python behaviors can my classes copy?
The third chapter shows how to overload comparison so objects holding the same data count as equal, how comparison works with inheritance, how to define string representations of objects, and how to create custom exceptions and handle exception hierarchies.
User Reviews
Write your review
You must be logged in to post a review.
Reviews can only be posted by registered learners. Log in or create a free account, then you will return here to post.


There are no reviews yet.