Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Python Basics Exercises: Building Systems With Classes (Summary)

Congratulations! You’ve now practiced using classes for object-oriented programming (OOP) in Python. Specifically, you can:

  • Compose classes together
  • Inherit and override behavior from other classes
  • Creatively mix and match these approaches

With these skills to your name, you’re now ready to tackle creating complex systems and writing sleek, Pythonic code.

If you want to dive deeper, then these written tutorials are for you:

Or you can explore the following video courses:

OOP is a big topic, and Real Python has more resources to help you expand your skill set. There’s even a learning path that’ll help you solidly grasp the fundamentals of OOP so that you can make your programs easier to write and maintain.

To continue your Python learning journey, check out the other Python Basics courses. You might also consider getting yourself a copy of Python Basics: A Practical Introduction to Python 3.


Sample Code (.zip)

17.7 MB

Course Slides (.pdf)

17.4 MB

00:00 Congratulations on making it through this Python Basics Exercises course. Here’s a quick summary of what you did, and I just want to highlight that there was a lot that you did in this course.

00:10 You practiced using classes, class attributes, instance attributes, non-public attributes, instance methods, even properties. You used special methods, you did inheritance a couple of times, you used composition and aggregation, used f-strings, and of course, you hopefully also practiced to use pen and paper and draw out your ideas.

00:34 Additionally to practicing coding concepts, there were also a couple of tips that you came across that might be helpful for your development in general. Draft your idea on pen and paper, use code comments to help you get organized, break exercises into smaller tasks, revisit your plan if you want to and update it.

00:51 Don’t worry about throwing out ideas that you had at the beginning while developing your code. Things might have changed. It’s always helpful to use descriptive variable names. That just makes reading your code so much easier.

01:03 It’s also helpful to create readable logging output is what I call this. Here in this course, I mostly did it by creating readable .__str__ methods and returning f-strings so that when running the code and testing it, the output would give me an idea to understand whether the code does what I expect it to do. Right, and I gave you some tips on how you could move that over to logging instead of using it as your return values. And I already mentioned that a bit, but going to test repeatedly to figure out whether the code actually does what you expect it to do is also very helpful because often you have an idea of what you think, you just code it up, but then it needs to hold up against the test of actually running it.

01:46 Keep practicing while you code. Keep them in mind that these are useful techniques while coding in general, and you can benefit from learning these across all the development that you do.

01:57 Now, here’s the promised additional resources. We have quite a lot in the course catalog about object-oriented programming. In the PDF that you can download that has all these slides, you can click the links on these additional resources, and they’re going to take you straight to the tutorial or video course.

02:14 And we have resources on inheritance and composition, about Python super(), about data classes, which is another way to create objects that is a little less involved than writing the classes the way that you did in this course.

02:28 We have resources on the @property decorator and also on providing multiple constructors to your Python classes.

02:37 There’s also a series of videos about object-oriented programming that tackles different aspects of it, so make sure to check this out as well. And they’re kind of loosely based on the Python classes tutorial that dives into the power of object-oriented programming.

02:54 So make sure to check out these additional resources if you want to learn more about OOP.

02:59 Thanks for joining me in this Python Basics Exercises course, and congratulations for making it all the way through, and hope to see you around at Real Python.

alphafox28js on Dec. 1, 2023

Output of the 98% of Code that Works is below for 1 animal. Functional and was Fun.

All of the Pitbulls are living on the farm. The Pitbulls move with a bold pace. They eat fast. They speak forcefully. Most run with purpose, but some slow. The hyper Pitbulls of the Canine Family jumps over the lazy dogs, and into the None. At night the Pitbulls sleeps peacefully and wake up slowly. All of the Animals and Farmers couldn’t be more happy!

The farm has Rolling Hills, 25mph winds, and large scatterd trees. It sits in the open plains. The Animalia run around and play all day. When it is time to feed, the Animalia, run to the the red barn. They eat from the Field. and to the barn. The Field has 1/10 spaces filled.

Martin Breuss RP Team on Dec. 6, 2023

@alphafox28js haha, I love your output! It’s very poetic!! :D

Become a Member to join the conversation.