Text Encoding & Binary Numbers
Overview
In this lesson, students will learn about ASCII encoding of text. Students will also look at how binary numbers can be used to store and transmit data on computer systems.
Purpose
All data is stored as binary 0s and 1s on a computer. This means that every image, video, document, and program we use on a computer is ultimately converted to binary. Looking at text is a way to see this process in a clear, understandable way.
Objectives
Students will be able to:
- Convert text to ASCII Numbers
- Convert base-10 numbers to base-2 binary
- Encode/decode a message using ASCII/Binary
Preparation
- Print the Code.org Flippy Do
- Print the ASCII Encoding Worksheet
- Print the Binary Conversion Worksheet
- Print the ASCII Hex Decoding Worksheet
- Download the AsciiEncoding.py python file.
Links
- For the Teacher
- https://en.wikipedia.org/wiki/Binary_number
- https://en.wikipedia.org/wiki/ASCII
- For the Students
- Binary Number Game
- https://studio.code.org/projects/applab/iukLbcDnzqgoxuu810unLw
Vocabulary
Number System: A method of representing numbers. Base-10: Our normal number system, 10 digits (0-9) can be in any number position Base-2: Binary number system only uses digits 0, 1 in any number position. ASCII: American Standard Code for Information Interchange - A method for representing every letter as a number.
Teaching Guide
Getting Started
- Discussion of how all data is stored as numbers in base-2 (binary) on a computer
The digits are stored as electrical pulses, magnetic poles in a Hard Drive, pits on a CD even as pulses of light. In all of these cases, there is a case that represents a 0 or 1.
As such, every bit of data is ultimately represented as binary numbers.
- Binary Numbers Video https://www.youtube.com/watch?v=1GSjbWt0c9M
- ASCII, Unicode, UTF8 encoding video https://www.youtube.com/watch?v=MijmeoH9LT4
Activity
Students will convert a message to ASCII using the chart. These will be base-10 numbers for now. Students will also decode a message and create their own message to swap and decode with another student.
Then students will convert a series of binary numbers to base-10 and back to text.
Activity (coding):
Python Programming:
- Using the AsciiEncoding.py as template:
- Create a text to ASCII to binary converter
- Try to convert each letter to the ASCII equivalent.
Wrap-up
Discussion
-
If all data is stored as 0s and 1s, how does a computer know if a file is text or a picture?
-
I can put a password on a document so it can’t be opened. If someone can see the 0s and 1s, what prevents someone from seeing the contents of that document? A password-protected documents is still stored as binary on the hard drive.
Assessment Questions
- Every letter is represented by a number, so is every color, sound, or program.
- If a color is a combination of red, green, and blue values (0-255), devise a way to hide text as an image.
Extended Learning
Standards Alignment
License
Cyber Security Curriculum is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.