< Unit 5 - Data and Society ('22-'23)

Lesson 5: Representing Numbers

45 minutes

Overview

Question of the Day: What system do computers use to represent numbers?

In this lesson, students learn about the binary number system. With a set of cards that represent the place values in a binary (base-2) number system by a collection of dots, students turn bits "on" or "off" by turning cards face up and face down, then observe the numbers that result from these different patterns. Eventually, students extend the pattern to a generic 4-bit system.

Purpose

Students learn how to use the binary system to represent integers. Unlike ASCII, which is presented as an arbitrary mapping of bit patterns to characters, binary numbers are introduced within the context of patterns of numbers. Students use the patterns to determine the binary representations of different numbers, rather than simply looking them up in a table.

Assessment Opportunities

  1. Use a binary system to represent numbers.

    Activity Guide, page 1: Student answers should match the key, noting that the last three questions may have different answers student to student.

  2. Extend a representation system based on patterns.

    Activity Guide, page 1: On the bottom of the page, students should correctly extend the pattern to 5- and 6-bit numbers.

CSTA K-12 Computer Science Standards (2017)
    • 2-DA-07 - Represent data using multiple encoding schemes.

Agenda

Objectives

Students will be able to:
  • Extend a representation system based on patterns.
  • Use a binary system to represent numbers.

Preparation

Links

Heads Up! Please make a copy of any documents you plan to share with students.

For the teachers
For the students

Teaching Guide

Warm Up (5 minutes)

Journal

Prompt: Create a list of all the information you might want to represent to a computer as a number. Here's some ideas to get you started

  • An online store (what kinds of numbers does a store keep track of?)
  • A social media profile (what things about you or your friends are numbers?)

Discuss: Students should brainstorm independently, then share with a partner, then finally discuss as a whole class.

Discussion Goal

Goal: In this and the following lessons students will be learning a new system to represent numbers using on-off signals. Motivate this activity by thinking back to the kinds of information students eventually will want to represent with this system. If students need help brainstorming give them a couple examples, e.g. age, their height, their birthday, the number of friends they have, the cost of items, an item's rating, etc.

Remarks

Numbers are a really useful and important way to represent all kinds of information. If we want to represent numbers to a computer, we're going to have to learn a new system that allows us to do that.

Question of the Day: What system do computers use to represent numbers?

Activity (35 minutes)

Group: Put students into pairs.

Distribute: Give each student a copy of the activity guide and a set of number cards.

Teaching Tip

For younger students, you may want to stop the activity after they have finished the first page of the worksheet. This means that they will not need to go online for any part of the lesson.

Representing Numbers Activity Guide

Model: Go through the example problem as a class. Ask students to arrange cards face up and face down so that exactly thirteen dots are showing. (It is important that each group uses only one set of cards.) After some trial and error, students should see that the 8, 4, and 1 cards should be face up, and the 2 card should be face down. (U U D U)

Teaching Tip

Digital Manipulatives: A digital version of the binary cards are provided in the teacher resources for you to make your own copy. To use with students: have the presentation open but not in “present” mode - this will let you move the cards as if you are covering or uncovering different cards.

Focus on Binary System: This activity models a base-2 number system for the student. However, it is not necessary for the students to understand the math behind the patterns that they are creating. Students should focus on the fact that they are using a binary system (face up/face down) to represent information.

Do This: Allow students to complete the rest of the front page of the activity in pairs. Instruct students to check with you before moving to the back page.

Circulate: Monitor students as they progress through the activity, looking for students working well in pairs. If students get stuck, suggest they use the number card manipulatives to help themselves out.

Share-Out: Ask students to share out their responses as a way of checking their answers. In particular, make sure the entire class agrees on the last few questions where they predict the pattern for 5-bit and 6-bit numbers.

Prompt: Was there more than one possible answer for any of the problems?

Discuss: Allow students to check with other pairs and try to find another way to represent the numbers before regrouping and discussing as a class.

Discussion Goal

Goal After some discussion, students should note that there is only one way to represent any particular number in this system. This is an important point to bring out because it would be confusing if two patterns meant the same thing.

Display: Have students flip to the back of their worksheet. In the top section, students will create a Binary Profile by answering a few questions and encoding their answers as binary numbers. Once completed, they will trade with a partner and use the widget to decode their binary profile to reveal the answers so humans can understand them.

Code Studio: Send students to the Binary Number widget.

Circulate: Allow students to complete the top half of the worksheet with the support of the widget. When both students in a pair have finished, have them trade papers to decode the other person's profile. When they finish, have them trade back and verify the answers were correct.

Challenge: If students have finished encoding and decoding their Binary profiles, have them create a new question that they can trade with another student in the room.

Prompt: The last question on this activity guide uses an 8-bit number, even though we haven't talked about how to represent these numbers yet. Do you think we can figure out what numbers are needed for 8-bit numbers? How?

Discussion Goal

Goal Students should recognize that the patterns of the numbers and the rules that they follow can help them determine the next numbers in the sequence. For an 8-bit number, starting from the left, the pattern goes 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1.

Allow students to discuss their ideas in pairs before bringing them back to the group.

Remarks

With these cards, we've created a binary system to represent numbers. Because we used a pattern that we can follow as our numbers get bigger, our system can work for as high as we can count.

Wrap Up (5 minutes)

Prompt: So far, we've looked at how we could represent text, images, and numbers in binary. Are there any other types of data that you use on your computer that need to be represented?

Allow students to call out different types of data, such as music, videos, etc.

Remarks

Those are all types of data that need to be represented in binary. We're going to watch a video that explains a little bit more about how this works.

Display: Play the "Binary and Data" video.

Questions to Consider with Video:

  • Why are all the types of data on the computer stored as numbers?
  • If everything is stored as a number, how do you think the computer tell the difference between numbers, letters, images, and sound?
Discussion Goal

The goal of this discussion is to have the students think more deeply about the purpose of binary.

For the first question, they may want to return to their ASCII character sheets and see how the computer would interpret the same binary sequence as a number. For their image representation, they may wonder whether it is even useful to interpret the binary sequences as numbers. In the end, the purpose of defining all data as numbers is less about the "reality" of what the ones and zeros represent, and more about how binary is traditionally interpreted.

For the second question, allow students to think of different ways that the computer would distinguish between different types of data. While it's not necessary for students to come up with any specific answer, challenge them in any ways that involve human interpretation of context, such as knowing that a name is most likely text and age is most likely a number. Assure them that they will look at the problem again in a couple of lessons.

Creative Commons License (CC BY-NC-SA 4.0).

This work is available under a Creative Commons License (CC BY-NC-SA 4.0).

If you are interested in licensing Code.org materials for commercial purposes contact us.