Teaching binary code with a secret word challenge Teach article
Do you find the binary system complicated? With this activity, your students will find it as easy as 01,10,11.
The binary numeral system plays a fundamental role in the way computers store data. They execute logic and arithmetic operations with two digits or states: 1/0, on/ off, yes/no, true/false. Standards like ASCII represent alphabets and symbols as numbers, which in turn get converted to the zeros and ones of binary code.
Through the activities described in this article, students will learn how to write numbers in the binary numeral system and decode a word written in a secret code based on binary code. The activities were designed for students aged 10-12 and can be completed with a whole class in a 50-minute lesson.
A number is a mathematical object used to count, order, or measure. The most common system used to represent numbers is the decimal system, where the base is 10 and the digits from 0 to 9 are used. The decimal system is classified as a positional notation; the value of each digit depends on its relative position. In contrast, roman numerals are non-positional since each symbol has a fixed value.
Another commonly used system is binary, or base 2. It has 0 and 1 as digits and is also a positional notation. Each 0 or 1 is called a bit (short for binary digit). For example, the number 45 is represented by 101101 using 6 bits.
101101 = 1 × 32 + 0 × 16 + 1 × 8 + 1 × 4 + 0 × 2 + 1 × 1 = 45
The binary system is widely used in computers, since it allows logical and arithmetic operations to be performed by using only 2 digits.
All digital electronics and computation are based on this binary system, in which it’s possible to represent numbers and characters, as well as perform logical and arithmetic operations through the use of digital electronic circuits called logic gates.
A line with white (1) and black (0) squares can also be used to represent a binary number. In this way, a secret code can be created in which each letter of the alphabet is assigned a number from 1 to 26 according to its position in the alphabet (e.g., B is 2 or 000010 in binary). Diacritics may also be represented by using numbers above 27.
The web apps provided with this article
Printable worksheets are provided with a variety of encoded mathematical words to use in the classroom activities described below. However, some students are very enthusiastic in cracking the secret code and just one word is not enough. Producing words manually using this secret code is time consuming and error-prone. To facilitate this, two web applications (web apps) were developed: one for teachers and one for students. Please see the attached Webb App Instructions for guidance on how to use them.
In the teachers’ web app, the teacher enters a word and a code is generated (figure 2) that can be printed for use in class. A page to facilitate online instruction in how to write numbers using the binary system is also provided.
The most eager students who quickly work through the prepared words can play the online game in the students’ web app (figure 3), which randomly generates an encoded word (from an uploaded dictionary or wordlist) and then verifies whether the answer is correct. A tab with information on the binary system and the objective of the game is also included.
The dictionary used in the game is a .txt file of scientific terms that the teacher can easily replace with a word list of their choice, with words in any language that uses the Latin alphabet.
Activity 1: writing numbers in the binary system
This activity introduces binary numbers in a way that encourages students to think it through themselves. It is an engaging way to develop computational thinking skills such as algorithmic thinking, abstraction, decomposition, generalizing, and patterns.
- A blackboard/whiteboard
- A set of six cards with 1,2, 4, 8, or 16 dots on one side and a black rectangle on the other (figure 4). Printable versions can be found here.
- Alternatively, for remote teaching, the online teaching resources in the teacher’s web app can be used.
Part 1: introduction to the binary system
- Ask the students if they own a computer or a smartphone. How do these machines store and share information?
- Explain that text, music, and images are represented using only two digits: 0 and 1.
- Write the numbers 0, 1, 2, 3 on the left side of the board underneath a horizontal line.
- Ask the students some questions in order to get a further three numbers between 0 and 64, and add these to the number column. We can ask for example:
- How many students are in the classroom?
- How many students have siblings/pets?
- How many have a name starting with a particular letter?
- Ask the students if they think we can write these numbers using just zeros and ones.
- Give a student volunteer (A) a card with one dot on one side and a black background on the other, and write 1 on the far right of the board above the horizontal line.
- Explain that 1 means on and 0 means off, so the black side represents 0. This way, we can represent the number 0 and 1.
- Give another volunteer (B) a card with two dots. Place this student on the left of the first one and write 2 to the left of 1 on the board.
- Ask them how they can, together, represent the number two. What about three? Ask the class for their ideas. Ask them to flip the cards to the on/off positions in order to help the discussion.
After this discussion the board should look like this:
Part 2: extending to larger numbers
- Place a third student volunteer (C) to the left of (B).
- Ask the students if they can figure out how many dots will be in the next card. Maybe someone will say 3 dots. Some others may see that the number 3 has already been written, so the next card will have 4 dots. Write the number four in the header line and then ask the class to write the next number, for instance a five:
- Ask for three more volunteers and place them on the left of the (C). Ask the students if they can figure out how many dots will be in these new cards.
- Maybe someone will answer 6 dots (4+2). Guide the discussion in order to get them to say 8, 16 and 32 dots.
- If the students are familiar with the concept of powers of two, use it to explain the pattern and how the binary system allows any number to be represented with zeros and ones based on powers of 2.
- Ask them to write the remaining numbers using only 0 and 1, and explain that we have to represent the numbers with all the cards/positions:
Activity 2: writing words with a secret code
- A printed example secret word in code to work through in class. You can also make a keychain version using black and white fuse beads.
- An additional secret word in code printed for each student. These can be from the attached worksheet or generated using the teachers’ web app.
- Present a word in binary representation in the form of a printed image or a key chain made with fuse beads. You can also use the example image above.
- Let the students know it represents a word. How can that be? They should arrive at the following conclusions:
- Each white bead/square represents 1 (light on).
- Each black bead/square represents 0 (light off).
- Each line represents a number written in binary system.
- Each letter of the alphabet can be represented by a number from 1 to 26.
- Ask the students to decode the numbers that are represented. In the example above, we have 10, 15, 28, and 15.
- Ask what numbers above 26 might represent. They should realize that several European languages use diacritical marks or accents, so 26 numbers are not enough (figure 5).
This gives us the following key for writing words in European languages:
- Now work through deciphering the secret word you gave them. The example above spells JOÃO (one of the authors of this article).
- Then give each student a different secret word written with binary code. Some students may need some help to crack it; others will be asking for more words and can help their fellow students.
- Ask each student to read their secret word. The examples provided are all maths-related words to celebrate International day of Mathematics. Some may be unknown to the students; these can be used as a starting point for further discussion.
- Use the students’ web app to play the Secret Word game.
- Ask the students to write secret words using fuse beads (figure 6) or squared paper. They might like to encode their own names.
- Replace the provided txt file in the students’ web app with a dictionary file or word list containing words on a fun theme, like animals.
- Connect this activity with other subjects like ICT, social studies (Morse code, women in science – notably Ada Lovelace), and art (creating a secret message with a melody or fuse beads, image pixelization).
- Discuss other numeral systems. The Babylonians used a sexagesimal system that is still present today in the way we track time. The vigesimal system, based on 20, was used by the Mayan civilization and some languages still represent some numbers this way, for example, quatre-vingt (‘four twenties’) for 80 in French, and res (short for tre-sinds-tyve or ‘three times twenty’) for 60 in Danish.
The lesson plan is inspired by binary numbers activities presented by CS Unplugged project (Computer Science Education Research Group, Canterbury University, New Zealand). We are grateful to Tim Bell for support with this work.
We are grateful to Carla Peres for welcoming this activity into her classroom with her students in 5th grade (February 2020, Escola EB 2,3 S. António, Faro).
Bell T et al. (2015) Computer Science Unplugged: an enrichment and extension programme for primary aged students. self-published .
Pedro A et al. (2017) Probótica Programação e Robótica no Ensino Básico: Linhas orientadoras. self-published .
Ramos J L et al. (2014) Os futuros professores e os professores do futuro. Os desafios da introdução ao pensamento computacional na escola, no currículo e na aprendizagem. Educação, Formação & Tecnologias. ISSN 1646-933X. 7:4–25.
- Teachers’ web app: https://www.scienceinschool.org/sis-game/Teacher/
- Students’ web app: https://www.scienceinschool.org/sis-game/Student/student-game.html
- Printable binary cards can be downloaded from the SC Unplugged website: https://csunplugged.org/en/resources/binary-cards/
- Find further activities on binary numbers on the Classic SC Unplugged website: https://classic.csunplugged.org/binary-numbers/
- Learn more about how computers work: www.khanacademy.org/computing/computers-and-internet/xcae6f4a7ff015e7d:digital-information
- Learn about simple programming using this classroom activity: https://www.scienceinschool.org/content/coding-without-computers
- Send your students’ codes to the International Space Station: https://astro-pi.org/
The activities described in the article can be used to help the students understand that though numbers represent real quantities, they may be expressed in many different ways using different systems. Specifically, the binary system is explored in an interactive manner, and through games. This can give the students an understanding of the language used by the computers and devices they so often interact with to store and retrieve information.
Using cards to represent each binary digit, and creating a secret code consisting of just 0 and 1, students learn to represent both numbers and words using these two symbols, as a computer does.
The article therefore also lends itself to exploring different ways of encoding or encrypting information (specifically text), and the rich history of codes throughout the ages (substitutional codes, vigenère cipher, morse, etc).
We carry out a similar activity to that described in this article with our students aged 10-11.
Antxon Anta and Elizabeth Goiri, Physics and Math Teachers, Colegio Aleman San Alberto Magno, Spain