Finish our Caesar Cipher using iteration,
conditionals, and converting data types
Completed
Encryption vs Encoding
Cryptography in History
Revisit Info Theory Concept
About Control Flow
Today
Finish our Caesar Cipher
Upcoming
Quiz
First, let's look at a few issues we'll run into based on the code we wrote last time.
Before we go further, let's talk a little bit about what's happening here.
When we use the ord() function, we are converting the character into a number based on ASCII encoding. ASCII is a standard encoding method, developed in the early 1960s, still used today across lots of technologies and softwares.
Unicode is pretty much the standard now, which we'll talk about later. However, unicode is built on top of ASCII, so you need to understand ASCII anyway.
We've been talking about control flow and variables and data types. It's important you under understand these concepts. Let's take another look at some of these ideas. This video is a snippet from a lecture on from an Intro to Programming & Python Class from MIT's OpenCourseWare.
When we started redesigning our Caesar Cipher program, we looked over control flow concepts, that is sequence, iteration (loops), and selection (conditionals aka if/else). In the next part of creating a better program, we will implement selection.
Selection is the more academic term, its more commonly referred to as conditionals or if/else. When using this control flow structure, you write code that only runs if a certain condition is met. The computer is going to check the condition, and it the condition is TRUE, it will run a group of code that you've specified. In the video from MIT with Dr. Ana Bell, she talked about that IF the player continues to walk right, they'll stay in the Lost Woods, but IF they walk left, then they'll escape the Lost Woods.
You could compare this to things in real life too, like IF it's a school day, wake up early, ELSE sleep later. First, you'll recognize whether or not it's a school day. You're 'checking' whether or not "today is a school_day" is equal to TRUE.
In python, that would look something like...
if today == school_day:
wake up = early
else:
wake up = late
IF it's hot outside, you'll wear a tshirt and a bottle of water with you.
First you'll check outside to see if its raining.
If "it's hot outside" is equal to TRUE, then you'll wear a tshirt and take a bottle of water.
These checks are an operation that produce a type of 'data' in programming, called a Boolean.
They can be either True or False.
So, to finish, we're going to use both selection and iteration in my Caesar Cipher Program.
TASK
At the end of today, you should have a Caesar Cipher program that uses both iteration and selection. This program should iterate through the plain text string, and convert each character one-by-one into an integer, change the value, and then convert it back into a character. Follow along with today's content to see how.
Finish and upload a video showing your Caesar Cipher program runs succesfully and utilizes the processes shown.