Operation Manual
Experiments in Python
83
Notes:
Binary Decimal
0 0
1 1
10 2
11 3
100 4
101 5
110 6
111 7
1000 8
1001 9
Bits and bytes
If you don’t already know, computers work in “binary”. Rather than counting from
0 to 9 for each unit as we do every day, they count from 0 to 1 for each unit. In
decimal numbers, from the right, the numbers are units, then 10s, 100s, 1000s
and so on. Each one is 10 times the previous one. In binary, the right-most
numbers is a unit, then 2s, 4s, 8s, and so on. Each one is 2 times (double) the
previous one.
Each unit in binary is called a “bit”, and this can have one of two values: 0 or 1
(electrically, “on” or “off”; logically, “true” or “false”). When computers add up
numbers, they need to have rows of bits to represent the numbers. By grouping
8 bits, we can make all the numbers from 0 to 255. This is known as a “byte”. If we
double to 16 bits we can have 65,536 different numbers (64k). You should start to
recognise some of these computer numbers: 2, 4, 8, 16, 32, 64, 128, 256…
Often, computer memory is sold in these sizes, and that is because they are made
to hold bits of data.
Here are the decimal numbers 0 to 9 as they appear in binary:
Live Pythons
The previous experiments have thrown you in the deep end, using IDLE to
enter programs and run them. IDLE requires you to have a graphical desktop
(called a “graphical user interface”, or “GUI”), but when you first started up your
Raspberry Pi, it just shows you a lot of text on screen. This is called the “terminal
console display”.
In the infancy of the Linux operating system (the system used by your
Raspberry Pi), GUIs were not common. Accessing a single computer was much
like accessing the internet today: a screen and keyboard set on a console table
with a wire into the back of a big box containing the hardware. When accessing
your computer over a wire like this, you would not want to wait for images to
download, so you simply had a text display. Watch any movie containing a
computer older than 1990 and you’ll see some examples. However, this is still the
most efficient way to control a computer and many web servers (those things that
send you web pages) are still maintained with a text interface.