Data Representation

What to expect

This chapter discusses binary, hexadecimal, character sets, images and sound. Some extracts are below.

Hand signals

We need to head over to France for an early binary code. Louis Braille injured an eye in his father’s leather workshop at the age of three, and the resulting infection caused him to go blind in both eyes by five. At age ten he obtained a scholarship to the Paris Institute for Blind Children, which at the time used a system of raised letters invented by Valentin Haüy. The letter shapes we know and love are not distinct enough to be easily discerned by touch, however, and Braille found Haüy’s system hard to learn.

While there, Braille was shown a system of raised dots used by the military to communicate at night. He took this system and improved upon it, using just six dots to represent all the letters of the alphabet plus numbers and some punctuation symbols. Each dot is raised or flat, and a blank space (effectively six flat dots) separates words and sentences. In this way, the grid of six dots could represent 2x2x2x2x2x2 = 26 or 64 different characters.

Magic Numbers

The importance of knowing the format of a file before processing it with application code is so important that there are two ways that a file identifies itself to the operating system. Windows uses file extensions such as .gif or .jpg and associates each extension with an application. It’s easy to accidentally change this extension, however, or even delete it. Meanwhile Unix-derived operating systems such as Linux and MacOS don’t use file associations anyway, so the metadata in the file header will also identify the content. For example, all JPEG files begin with the two bytes FFD8 in hex, GIFs begin with the ASCII string GIF89a, and PDFs begin %PDF. Because this trick originally used only numeric codes, this identifying string is still sometimes called the file’s “magic number”.


The number of possible colours in a bitmap image is equal to the number of bits per pixel, so 4 bits gives 4 colours.


The number of possible colours is calculated as 2^bit depth, so 4 bits gives 2^4 = 16 colours, and 8 bits gives 2^8 = 256 colours. This misconception can be tackled by doing some student activities with low bit depths from 1 to 4, so they can see how the number of bit patterns, therefore the number of colours, doubles each time you add a bit.


The PCK section in this chapter includes these references:

Use Python with an image library such as PIL, create and demonstrate some sample code, and then allow the students to edit it to make their own image filters. Some sample code is here, this program is easily edited to change the colour cast of a JPEG image. .

Martin O’ Hanlon has created a whole course on using Python with image filters here:

Image filters (above) are a great means of linking programming to data representation. You could also link Programming with sound data, using a Python library such as wave

Bitmap image creation is a great topic for unplugged activities. Give the learners a grid of empty pixels and a colour code and ask them to reveal the picture. They can then make their own picture, save it as numeric data and give the numbers to a partner who then reveals the image. Some sample activities of this nature are here:

The Micro:Bit™ has a built in 5 by 5 grid of LEDs which can be set easily with blocks or text coding, perfect for teaching 1-bit bitmaps. If you have a Raspberry Pi with the camera attachment, you can take pictures and process them with Python. You can use the Minecraft API to store these images in a “photobooth” within the Minecraft world with this tutorial here:

Using the open-source software Audacity, learners can get hands on with sound recordings, finding out how the sample rate and bit depth affects sound quality and file size. The NCCE resources include a great lesson on this here:  Add a microphone for even more hands-on fun.

More references here

Paiute War – Wikipedia

[21] Ada Lovelace from












[33] .

[34] ,,