Free tools for teaching data representation of images with python

In Computing at KS3 in England, students have to learn how images can be stored and manipulated using binary data.

Pupils should be taught to:

…understand how instructions are stored and executed within a computer system; understand how data of various types (including text, sounds and pictures) can be represented and manipulated digitally, in the form of binary digits

This can be a tough part of the curriculum to cover in the limited time available to most schools but it can also be a really exciting way of bridging the gap between the Computer Science and iMedia / IT facets of the course.

In order to follow up from a series of lessons using Photoshop to create and manipulate high quality graphics, I wanted students to be able to understand how the images that they’d just created were stored on a computer.

There are some excellent ‘unplugged’ resources out there where students can see how simple images can be represented by binary data but I wanted Y8 students to be able to write, edit and debug some simple python code that showed them how computers store and process images.

There are two main ways that computers use binary data to represent images. This blog post details how you can use free web based tools to get students to explore how computers can represent and manipulate both bitmap and vector images.

Data representation of images: Bitmap images
Data representation of images: Bitmap images
Data representation of images: Vector images
Data representation of images: Vector images using

The next page gives some activity ideas for getting students to understand how vector images work.

Continue ReadingFree tools for teaching data representation of images with python
Microbit tetris in python
Microbit tetris in python

microbit Tetris in python

I’ve finally got round to updating the online microbit python simulator in to catch up with some of the amazing new micropython features (such as speech and radio).

To celebrate, here are three different versions of the classic game tetris that you can simulate online in a virtual microbit or download to your device and play.

Microbit tetris in python
microbit tetris in python

First version

The first two tetris games weren’t made by me: the first was made by VivianePons and donated into the public domain after making it at PyCon2016.

It uses the microbit’s accelerometer to sense how much you tilt the device in order to move the blocks left and right. You can play it in the simulator by clicking on the accelerometer tab and changing the X slider left and right.

Second version

The second version of tetris comes from the excellent tutorial at 101 Computing. It uses buttons A and B to move the blocks and you get different shapes that you can rotate by pressing both buttons rather than a single dot:

Which version do you prefer? Can you combine the best bits of both programs? I think it’d be great it you could use the accelerometer like the first version but have the more complex blocks that you can rotate like the second one. Perhaps button A would rotate counter clockwise and button B clockwise. Post a comment with a link to your code if you’re able to improve on either of these projects and thanks to the original authors for sharing their code online.


Update 28/3/2017:

It seems that the second version doesn’t work any more with the current version of micropython for a micro:bit.

Please see below for a version of Tetris I’ve put together that works on both the simulator and an actual device.

There are four different types of blocks that fall down. You can move them by pressing A or B or rotate them by tilting the microbit left or right.

Have fun!

Continue Readingmicrobit Tetris in python
Create with code
Write, run, debug and share python code with online python editor is now open source! is an online python editor that allows you to write, run, debug and share python code in your web browser. It launched in April 2016 to help students learn to write code on any device without having to install any specialist software.

In June 2016 I added a BBC microbit simulator to make it easier for my students to write, debug and share python code for a BBC micro:bit. Since then, I’ve been approached by a number of different people to see if they can adapt or extend some of the features on this site. All of the resources on this site are published under the Creative Commons share-alike license which means you’re free to use anything here for whatever purpose as long as you reference me as the original author. Up until now though, whilst has been free to use, the source code that makes it work hasn’t been openly available. I’m really grateful to those of you who have got in touch to request a feature or report a bug but I’ve been really impressed with the response to the site from people who have ideas of how to make it even better.

I’m pleased to announce that is now open-source. This means that if you can think of a way to improve the python editor or you spot a bug that needs fixing, you don’t have to wait for me to code it: you can jump right in and adapt / extend / improve it however you like. You’re free to use it for your own projects – I’d love to hear from you if you find a use for it.

You can find the source code for here.

If I had the time, I’d love to extend or adapt for the following:

  • self marking python tests that integrate with moodle
  • create 3d games and objects using python
  • interactive competitive python quizzes that integrate with moodle

The possibilities are endless (but time is very limited!) so hopefully going open source will allow someone to get creative and innovative without me holding them back!



Continue online python editor is now open source!