Python Basics Exercises: Building Systems With Classes (Overview)

In Python Basics: Building Systems With Classes, you moved beyond the basics of object-oriented programming (OOP), and started to put those classes to work. In this exercise course you will employ these capabilities to build more complex systems and write readable, reusable code.

In this video course, you’ll practice the following:

  • Compose classes together to create layers of functionality
  • Inherit and override behavior from other classes to create variations
  • Creatively mix and match these approaches
  • Instantiate classes with attributes and methods
  • Override methods from a parent class

This video course is part of the Python Basics series, which accompanies Python Basics: A Practical Introduction to Python 3.

Note that you’ll be using IDLE to interact with Python throughout this course. If you’re just getting started, then you might want to check out Python Basics: Setting Up Python before diving into this course.


Sample Code (.zip)

17.7 MB

Course Slides (.pdf)

17.4 MB

00:00 Welcome to this Real Python Exercises course where you’ll practice building systems with classes. Our exercise courses are all about training. You’ll train the process of writing code by solving carefully selected exercises.

00:13 You’ll also train reading other people’s code and communicating your thought process. Doing all that, you’ll practice the concepts that you’ve learned about in an associated course or tutorial and help make them stick. In upcoming lessons, I’ll introduce tasks, give you an opportunity to solve them yourself, and then show you step by step how I solved each of them.

00:34 So I’ll go through three steps for each task. You’ll learn about the exercise, you’ll code your own solution, and then you’ll compare your solution and the process that got you there to mine. When I walk you through a task, I’ll explain what I do and also why I do it like that.

00:49 That’ll give you a chance to compare not just our final solutions, but also how we got there. Ideally, this can help you gain some insight on the process of getting from a task description to a working solution in code.

01:01 You’ll start by solving some review exercises in the first section of the course and build up towards a challenge. In the second section, you’ll actually train building systems with classes in Python.

01:13 The challenge in this course will be quite big and open-ended. It’ll give you a chance to revisit fundamental OOP concepts, inheritance, composition, and how to make it all fit together to build something meaningful.

01:24 Because the challenge is quite big, and it took a lot of lessons when I wrote the code, you’ll see a third section in this course. There’ll be a continuation of the challenge that you’ll start at the beginning of section two. Don’t peek ahead. Okay, so now the big question: are you ready for this course?

01:42 The idea for this exercises course is that you should have watched the Python Basics course on Building Systems With Classes before starting this one. If you went through that course, then you’re well equipped to solve the tasks that you’re about to encounter.

01:55 The concepts that you should have heard about and will practice are Python classes, attributes, and methods. So that’s class attributes and instance attributes, instance methods, special methods, et cetera, and f-strings.

02:08 If you’re already somewhat familiar with these concepts, but you want to fortify your knowledge with practical programming tasks, then this course is exactly right for you. Before we get started, there’s another tiny bit of background for this course, which is that I’ll use IDLE, the Integrated Development and Learning Environment that comes with Python.

02:28 If you’ve gone through the Python Basics courses, then you’re already familiar with the tool. If not, and you want to know more, then you can check out these associated courses that cover getting started with IDLE.

02:38 I’ll use IDLE’s interactive console that gives you direct access to the code defined in a Python file you executed. This makes it a bit more interactive when testing your code, but you don’t need to use that feature, and you can replace it with print() calls at the end of your file.

02:52 So if you’re here to train outside of the Python Basics courses, feel free to use whatever tool you like to solve the upcoming coding tasks,

03:00 and that’s all there is to say to get you set up. If you’re ready to get started and do hands-on programming, then see you in the next lesson. There, you’ll get to know the first review exercise, which as you can see from this immaculate modeling code, will be your entry point before we crank up the difficulty.

03:15 Well, crank it up one step, but what do numbers in isolation mean at all? How many levels are there? Two? One hundred? Wait, am I questioning the class system I built here?

Become a Member to join the conversation.