Today, we’re going to take a look at how computers use a stream of 1s and 0s to represent all of our data - from our text messages and photos to music and webpages. We’re going to focus on how these binary values are used to represent numbers and letters and discuss how our need to perform operations on larger and more complex values brought us from our 8-bit video games to beautiful Instagram photos, and from the unreadable garbled text in our emails to a universal language encoding scheme.
The binary number system plays a central role in how information of all kinds is stored on computers. Understanding binary can lift a lot of the mystery from computers, because at a fundamental level they’re really just machines for flipping binary digits on and off. There are several activities on binary numbers in this document, all simple enough that they can be used to teach the binary system to anyone who can count! Generally children learn the binary system very quickly using this approach, but we find that many adults are also excited when they finally understand what bits and bytes really are.
Available in 13 languages.
Images are everywhere on computers. Some are obvious, like photos on web pages and icons on buttons, but others are more subtle: a font is really a collection of images of characters, and a fax machine is really a computer that is good at scanning and printing.
This activity explores how images as data structures are displayed, based on the pixel as a building block. In particular, the great quantity of data in an image means that we need to use compression to be able to store and transmit it efficiently. The compression method used in this activity is based on the one used in fax machines, for black and white images.
Many computer users are familiar with compressed formats such as zip, gzip, or gif images. These are based on a method called Ziv-Lempel coding, which turns out to be an interesting exercise in finding patterns in text.
Children’s rhymes and stories are good examples of text compression because they often involve repeated words and sequences.
The world is a noisy place, and errors can occur whenever information is stored or transmitted. Error detection techniques add extra parity bits to data to determine when errors have occurred.
This activity is a magic trick which most audiences find intriguing. In the trick the demonstrator is “magically” able to figure which one out of dozens of cards has been turned over, using the same methods that computers use to figure out if an error has occurred in data storage.
This activity involves listening to songs and finding hidden messages based on the same principle as a modem.
The binary number activity briefly mentions how text could be coded using sound — high and low beeps represent binary digits, which in turn can be decoded to numbers that represent the letters of the alphabet.
All data on computers is stored and transmitted using the binary number system. When the binary digits need to be sent over phone lines which used to be standard in home internet connections, the digits are converted to sound and decoded at the other end, using a modem. This activity uses an audio coding similar to that used by a modem, but the sounds are recorded as songs, which students can decode.
Learn how text, images, and sound are converted into binary so they can be processed by a computer and how images and sound are compressed to create smaller files.
Includes information on ASCII, unicode, binary, pixels, bits, analog, digital, data compression, lossless compression.
This webpage provides an introduction to how data is stored in computers, including a brief explanation of the binary numbering system.
Computers can only work with digital information. Everything that they process must first be turned into a digital signal in one of two states: "on" or "off."
At a basic level, a computer processor is a collection of switches which can either be on or off. These switches are known as transistors. The computer processes information by switching transistors on and off automatically.
Information from input devices must be digitized so the information can be processed.
Data is stored differently depending on its type. Numbers are stored as integers or real numbers, text as string or characters. Lists of the same type of data can be stored in an array.
This webpage examines integer data, real or float data, characters, strings, boolean values, and arrays.
In this multi-day lesson, the class uses the problem-solving process from Unit 1 to create a platform jumper game. After looking at a sample game, the class defines what their games will look like and uses a structured process to build them. Finally, the class reflects on how the games could be improved and implements those changes.
Note: You will need to create a free account on code.org before you can view this resource.
The class designs structure to represent their perfect day using the binary representation systems they've learned in this chapter. After deciding which pieces of information the record should capture, the class will decide how a punch card of bytes of information will be interpreted to represent those pieces of information. Afterward, everyone will use the ASCII, binary number, and image formats they have learned to represent their perfect days to try to decipher what a partner's perfect day is like.
This lesson combines all three types of binary representation systems (ASCII characters, binary number, and images) to allow for the encoding of more complex types of information in a record. After seeing a series of bits and being asked to decode them, the class is introduced to the idea that understanding binary information requires the understanding of both the system that is being used and the meaning of the information encoded.
This lesson introduces the binary number system. With a set of cards that represent the place values in a binary (base-2) number system, the class turns bits "on" or "off" by turning cards face up and face down, then observes the numbers that result from these different patterns. Eventually, the pattern is extended to a generic 4-bit system.
This lesson continues the study of binary representation systems, this time with images. The class is introduced to the concept of splitting images into squares or "pixels," which can then be turned on or off individually to make the entire image. After doing a short set of challenges using the Pixelation Widget, the class makes connections between the system for representing images and the system for representing text they learned in the previous lesson.
This lesson introduces a formal binary system for encoding information, the ASCII system for representing letters and other characters. At the beginning of the lesson, the teacher introduces the fact that computers must represent information using either "on" or "off". The class is then introduced to the ASCII system for representing text using binary symbols and practices using this system before encoding their own messages using ASCII.
The class learns about collision detection on the computer. Pairs explore how a computer could use sprite location, size properties, and math to detect whether two sprites are touching. The class then uses the isTouching() block to create different effects when sprites collide, including playing sounds. Last, they use their new skills to improve the sidescroller game that they started in the last lesson.
The class learns to combine the velocity properties of sprites with the counter pattern to create more complex sprite movement, such as simulating gravity, making a sprite jump, and allowing a sprite to float left or right. In the final levels, the class combines these movements to animate and control a single sprite and build a simple game in which a character flies around and collects coins.
The class programs their sprites to interact in new ways. After a brief review of how they used the isTouching block, the class brainstorms other ways that two sprites could interact. They then use isTouching to make one sprite push another across the screen before practicing with the four collision blocks (collide, displace, bounce, and bounceOff).
This lesson covers functions as a way to organize code, make it more readable, and remove repeated blocks of code. The class learns that higher level or more abstract steps make it easier to understand and reason about steps, then begins to create functions in Game Lab. At the end of the lesson, the class uses these skills to organize and add functionality to the final version of their side scroller game.