
This course includes our updated coding exercises so you can practice your skills as you learn.
See a demo
Explore why object oriented programming matters, compare it with procedural programming, and master core concepts like inheritance, encapsulation, polymorphism, and classes and objects in Python.
Explore what object oriented programming is by contrasting it with procedural programming, using an employee data example to show objects with attributes and methods, and emphasize readability and mindset.
Explore inheritance, polymorphism, and encapsulation through human and employee objects. See how these concepts transfer to any language and why encapsulation hides the implementation.
Understand how classes define blueprints and types, while objects are instantiated instances with attributes and methods. See how a class design becomes actual objects in memory through instantiation.
Learn how to define a Python class, instantiate objects, and manage object attributes such as name, age, and salary, including reading, modifying, and handling missing attributes.
Explore how the id() function reveals memory addresses of Python objects, including instances and classes, and how the is operator compares them.
Explore how objects and classes are laid out in memory, visualize memory addresses, and see how mutable and immutable objects behave with references and the id function.
Learn to express an object's behavior by defining methods in a Python class, using self, and manipulating attributes like salary and age.
Learn how to initialize object attributes in Python with the __init__ method, enforce required name, age, and salary, and use self and optional keyword arguments with defaults.
Explore encapsulation in Python by distinguishing public interfaces from private implementation details, using single underscores for privacy by convention, and understanding name mangling for double underscores.
Explore mac's hand wins, a 52-card deck game where three players draw two cards, determine round winners by rank then suit, with ace highest and spades strongest, tracking scores.
Explore how class attributes are shared across all instances and how instance attributes differ, learn Python's attribute resolution, and see how changes affect apples' food type and calories.
Explore the differences between instance methods, class methods, and static methods in Python OOP, using self, cls, and decorators to manage class variables like calories and food type.
Demonstrate inheritance by modeling a person as the base class and employee and student as its subclasses, removing redundancy while preserving shared attributes.
Explore inheritance from a person class to an employee class and override the full name method to customize behavior, demonstrating inherited methods and class attributes.
Explore constructor inheritance and method overriding using a person and employee class hierarchy, demonstrating how super simplifies init and info methods, reduces redundancy, and supports role-specific salary adjustments.
Explore magic methods in Python, the two-underscore special methods used for operator overloading. Learn how __init__ initializes objects and how __add__ customizes the plus operator for your classes.
Explore arithmetic magic methods by modeling a complex number class with real and imaginary parts, and implement the dunder add method to support addition, subtraction, and multiplication in Python.
Define the __add__ magic method to enable the plus operator on a complex number class, converting a regular add method into a dunder method, demonstrated with 7 + 4.
Define the Dundar sub method to overload the minus operator for a complex number class, subtracting real and imaginary parts and returning a new complex number instance.
Define the __mul__ magic method to implement the multiplication operator for a complex number, handling real and imaginary parts, with tips on other arithmetic and comparison magic methods.
Explore Python's six comparison magic methods, including __eq__, __ne__, __gt__, __lt__, __ge__, and __le__. Learn that the object base class defines them by default and how to override them.
Explore how Python handles equality and inequality, using the employee class to show default ID based comparisons, and how defining __eq__ (and optionally __ne__) changes results.
Learn how to implement Python's comparison magic methods by defining equality and greater-than operators, and use total_ordering to deduce less-than, less-than-or-equal, and greater-than-or-equal for an employee class.
Explore the __str__ magic method for user-friendly string representations, see how print and str() invoke it, and learn to override it in classes like employee or complex number.
Important: This course is NOT for absolute beginners. Object-oriented programming / design is for intermediate-level learners.
Object-oriented programming (OOP) is a programming model that is widely used in the industry.
Mastering OOP concepts allows you to write code that is readable, maintainable, reusable, and overall more elegant. All of these are skills that separate high-performing programmers from average programmers.
Everything in Python is actually an object! This means that your understanding of the Python programming language is not complete until you fully internalize OOP concepts and understand how to apply these concepts in Python.
So if you want to be a solid Python programmer, then understanding OOP concepts, learning how to design, implement, and apply these concepts in your code is crucial.
What You Will Learn
Write clean code that is reusable, modular, and readable
Level up your Python programming skills
Learn the fundamental object-oriented programming concepts
Apply OOP concepts to your Python code
Work on a project to enhance your understanding of the course
Good and bad practices when writing OOP code
This course is for you if you:
have basic knowledge of Python and wants to take your skills to the next level
want to learn the fundamental concepts of object-oriented programming
want to learn how to apply object-oriented programming concepts in Python
like to learn concepts in-depth
like to learn by doing homework and working on a project
What are the prerequisites for this course?
This course is about object-oriented programming in Python. I assume that you have a fairly basic knowledge of the Python programming language. For example, you know what variables, for loops, functions, lists, and dictionaries are.