This tutorial will help students (specifically those in grades 6+ with at least some background in code/programming) learn to make a "secret message" encoded/decoder in Python! We will mainly focus on the ITEEA Standard for Technological Literacy number 17, which states that "students will develop an understanding of and be able to select and use information and communication technologies" (https://www.iteea.org/File.aspx?id=67767). In specific, our lesson will teach students the basic concepts of message encoding/decoding, which is used in pretty much all modern communications (and is a step towards the advanced topics of encryption and decryption).
Students will learn:
- The concepts of encoding and decoding information for sending
- Installing and using basic Python on a Windows machine
- Fundamentals of cryptography (Caesar cipher)
- Why we encode/decode information
- Real world applications for such program
- Access to a computer running Windows with a network connection and Python 3.7 installed
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Installing Python
Before we can use Python to make anything, we need to install it on the computers that the students will be using. If you're using school owned computers, the IT department will likely need to help you with this since they have administrator privileges to install programs. Otherwise, the link for the installer can be found here: https://www.python.org/downloads/release/python-370/. Once the file downloads, just run it and click Next until Python is installed.
Step 2: Learning the Basics of Message Encoding/Encryption
Before we can walk through how to help students create the encoding program, we need to first teach them the basics of what encoding is and why it's used. In short: message encoding is the process of getting it ready for transmission to the receiver. This part is done by the message sender, and is expected to be decoded on the receiving end. After the message is received and decoded, the receiver should be able to understand the message and what was meant. A good distinction to make to students is the difference between encoding and encryption; encoding is meant to be used just for transmission and not as a security measure. To make sure that nobody else could read sensitive information, you would need to use encryption of some sort, which is much harder to "crack" so to speak. In our tutorial today we'll be using a simple Caesar cipher to introduce these concepts, although it is by no means secure.
Step 3: Starting to Use Python's IDLE Editor
Luckily for us, Python comes with a decent code editor/compiler built in (called IDLE). We can use this simple program to let our students code in Python without getting too distracted or lost. Have your students open their Windows start menu and find the IDLE (Python) program and open it, they should get a shell window from where you can start a New File as seen in the screen shot. Once students have a blank program file open to type in, we're ready to start writing the program.
Step 4: Filling Out the Program
Today we won't be necessarily teaching students all the ins and outs of Python and how to write it from scratch, but rather guiding them to the concepts of getting a program working on their own computer that they can then edit and run. For convenience today I've included the full program code for download, and we'll run through quickly what the different parts do for the students:
- cipherMessage() is where students will put the code that will encode our message. This function handles taking in the user message to encode, the number of places to shift it by, applies that shift to each character, then puts the message back together and prints it out for the student.
- decipherMessage() is pretty much the same as the above function, just applying that shift backwards so the user gets their originally transmitted message back, provided they know the shift number!
- The bottom two lines just call the above functions for testing, so the students can encode a message and decode it to see it working
Step 5: Running the Program
Once the students have the program ready in IDLE, running it is very simple. All students need to do is go under the Run tab up top on IDLE and select "Run Module". Once done, that'll give them a new window where the program is running. From here students can use the program with a test message and shift number (this number can be anything so longer as it's the same for encoding and decoding). This point would be a good time to let students use the program, and you can circle the classroom to help any students having trouble.
Step 6: Example Run
Here's an example of a program run, and as you can see we get the same message as output as we put in the input. In short, this program takes each character in our message, and "shifts" it to the right in the alphabet according to our shift number. For example, if there's an "a" in our message, and our shift number is 2, that character would become a "c". The program repeats that for each character in the message, then puts it back together for the output.
From here, a good next step for students to learn would be a lesson on encryption techniques like the ones our web browsers use to send sensitive information such as passwords and credit card numbers.