Skip main navigation

How to Draw Shapes in Python

You are now going to draw some shapes using objects. Note: Unfortunately, you won’t be able to complete this activity if you are using an online IDE such as Trinket …

Python Turtle Race

In this step you will be writing a program using objects, using Python’s turtle module to create a turtle race.       1. Create a new Python program and …

Cement your knowledge of objects

Note: There is no speech on the video above, and all of the steps in the video are described below. So far, you have learnt that an object has attributes …

Example: using objects to create a GUI

Here is another example to show how objects are used in a program – this time to represent buttons on an interface. This is just a demonstration of the principle …

Introduction

I’m Laura Sach, Senior Learning Manager at the Raspberry Pi Foundation, and I am your lead educator for this course. I am part of the Education team and I write …

Share your code with other people

Sharing your code with other people need not be limited to people you know. It is very easy to share your code online so that anyone, anywhere can use it. …

Packaging your code

Congratulations, you have now created your own adventure game in object-oriented style! One of the benefits of writing your code in this programming style is that you can share the …

Class diagrams

To represent inheritance between classes, you can use a class diagram showing which classes inherit from which other classes. This may make the terms ‘superclass’ and ‘subclass’ easier to remember, …

Adding new attributes and methods

At the moment our Enemy class is functionally identical to the Character class, which is a bit pointless. That’s why we’ll start to add new functionality to customise it. Let’s …

Extending an existing class

This week we’re going to extend an existing class. This means we will create another class which uses the functionality of the existing class, but also adds to or overwrites …

Instantiating your own object

Now that we have written some code, let’s test it out by creating an object of the Room class we have written. If you are using Trinket, you will already …