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.

Image: aranjuezmedina/
www.freepik.com

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.

Binary Code

Image courtesy of
Anabela Estudante

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.

Figure 1: Different representations for the number 45.
Image courtesy of Anabela Estudante

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 Web 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.

Figure 2: The teacher’s web app. a) An example of the code generator.
b) A Snapshot of the remote teaching resource page.
Image courtesy of Anabela Estudante

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.

Figure 3: One round of the game for students, with the provided keys, the code, and the checking function.
Image courtesy of Anabela Estudante

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.

Materials

Figure 4:  Binary cards at work.
Image: CS Unplugged, CC BY-SA 
  • 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

5th grade students learning to write numbers in the binary system.
Image courtesy of Carla Peres
  1. Ask the students if they own a computer or a smartphone. How do these machines store and share information?
  2. Explain that text, music, and images are represented using only two digits: 0 and 1.
  3. Write the numbers 0, 1, 2, 3 on the left side of the board underneath a horizontal line.
  4. 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:
  1. How many students are in the classroom?
  2. How many students have siblings/pets?
  3. How many have a name starting with a particular letter?
  1. Ask the students if they think we can write these numbers using just zeros and ones.
  2. 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.
  3. 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.
  4. 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.
  5. 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:

​Image courtesy of João Pedro Lourenço

Part 2: extending to larger numbers

  1. Place a third student volunteer (C) to the left of (B).
  2. 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:
​Image courtesy of João Pedro Lourenço
  1. 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.
  2. Maybe someone will answer 6 dots (4+2). Guide the discussion in order to get them to say 8, 16 and 32 dots.
  3. 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.
  4. 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:
​Image courtesy of João Pedro Lourenço

Activity 2: writing words with a secret code

Materials

  • 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.
Key chain with the word JOÃO
Image courtesy of Anabela Estudante

Procedure

  1. 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.
  2. 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.
  1. Ask the students to decode the numbers that are represented. In the example above, we have 10, 15, 28, and 15.
  2. 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).
Figure 5: Diacritics in European languages
Image: Jakub Marian

 This gives us the following key for writing words in European languages:

Matching letters and diacritics with numbers
​Image courtesy of Anabela Estudante
  1. Now work through deciphering the secret word you gave them. The example above spells JOÃO (one of the authors of this article).
  2. 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.
  3. 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.

Extension activities

  1. Use the students’ web app to play the Secret Word game.
  2. Ask the students to write secret words using fuse beads (figure 6) or squared paper. They might like to encode their own names.
Figure 6: Making binary code keychains using black and white fuse beads.
Image courtesy of Anabela Estudante
  1. 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.
  2. 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).
  3. 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.

Acknowledgement

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).


References

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 orientadorasself-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.

Resources

Author(s)

Anabela Estudante is a chemistry and physics teacher and coordinator of a science club in Agrupamento de Escolas João de Deus, Faro, Portugal. With a degree in chemical engineering and a masters degree in library and information science, she is also interested in computer sciences and robotics.

João Lourenço is a master’s student in Computer Science Engineering at Instituto Superior Técnico, and participated in an Erasmus exchange at Lund University during the whole 2020/2021 school year.

Together they created an Educational Resource nominated for the Casa das Ciências 2018 best resource prize.

Review

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

License

CC-BY
Text released under the Creative Commons CC-BY license. Images: please see individual descriptions