Objects and classes
Designing your own types, reusing them through inheritance, and making them work with Python's built-in operations.
About 6 hours of study
Learning objectives
- Design classes with attributes and methods
- Reuse code with inheritance and super
- Add special methods to your classes
Lessons
- 1
Classes and objects Intermediate
Design your own types with attributes and methods, and watch objects live in memory.
- 2
Inheritance Intermediate
Build new classes on top of old ones, override methods, and call the parent with super().
- 3
Special methods Intermediate
Make your objects print nicely, compare with ==, add with +, and work with len().
Module practice
- A Temperature classEasy
- Bank accountMedium
- Rectangle classMedium
- A small libraryHard
- Animal soundsEasy
- Shapes with one interfaceMedium
- PayrollHard
- A printable pointEasy
- Adding fractionsMedium
- Vectors that behave like numbersHard