Loved by learners at thousands of companies
Object-oriented programming (OOP) is a widely used programming paradigm that reduces development times—making it easier to read, reuse, and maintain your code. OOP shifts the focus from thinking about code as a sequence of actions to looking at your program as a collection of objects that interact with each other. In this course, you’ll learn how to create classes, which act as the blueprints for every object in Python. You’ll then leverage principles called inheritance and polymorphism to reuse and optimize code. Dive in and learn how to create beautiful code that’s clean and efficient!
In this chapter, you'll learn what object-oriented programming (OOP) is, how it differs from procedural-programming, and how it can be applied. You'll then define your own classes, and learn how to create methods, attributes, and constructors.What is OOP?50 xpOOP termininology100 xpExploring object interface100 xpClass anatomy: attributes and methods50 xpUnderstanding class definitions100 xpCreate your first class100 xpUsing attributes in class definition100 xpClass anatomy: the __init__ constructor50 xpCorrect use of __init__50 xpAdd a class constructor100 xpWrite a class from scratch100 xp
Inheritance and Polymorphism
Inheritance and polymorphism are the core concepts of OOP that enable efficient and consistent code reuse. Learn how to inherit from a class, customize and redefine methods, and review the differences between class-level data and instance-level data.Instance and class data50 xpClass-level attributes100 xpChanging class attributes100 xpAlternative constructors100 xpClass inheritance50 xpUnderstanding inheritance100 xpCreate a subclass100 xpCustomizing functionality via inheritance50 xpMethod inheritance100 xpInheritance of class attributes100 xpCustomizing a DataFrame100 xp
Integrating with Standard Python
In this chapter, you'll learn how to make sure that objects that store the same data are considered equal, how to define and customize string representations of objects, and even how to create new error types. Through interactive exercises, you’ll learn how to further customize your classes to make them work more like standard Python data types.Operator overloading: comparison50 xpOverloading equality100 xpChecking class equality100 xpComparison and inheritance100 xpOperator overloading: string representation50 xpString formatting review100 xpString representation of objects100 xpExceptions50 xpCatching exceptions100 xpCustom exceptions100 xpHandling exception hierarchies100 xp
Best Practices of Class Design
How do you design classes for inheritance? Does Python have private attributes? Is it possible to control attribute access? You'll find answers to these questions (and more) as you learn class design best practices.Designing for inheritance and polymorphism50 xpPolymorphic methods50 xpSquare and rectangle100 xpManaging data access: private attributes50 xpAttribute naming conventions100 xpUsing internal attributes100 xpProperties50 xpWhat do properties do?50 xpCreate and set properties100 xpRead-only properties100 xpCongratulations!50 xp
PrerequisitesWriting Functions in Python
Don’t just take our word for it
- Kostyantyn T.6 days
The course is well organized and presented. It provides a good introduction to Python OOP features.
- Bob J.15 days
OOP is an essential component of Python programming and key to other key concepts like Error Handling, Custom Class, etc. This is a valuable course with lot of samples and exercises.
- Dhalton27 days
The explanations are very clear and the exercises are very objectives.
- Lyndon H.about 1 month
Good explanation of the syntax of the OOP implementation. As a Java Programmer I particularly liked the explanation that Python is for grown-ups and you can return to wild west programming if so inclined.
- Yash M.about 1 month