Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5. In-class assignment: Mystery Texts You've come across five mysterious texts that have been encoded with a Caesar cipher. Your job is to design a

5. In-class assignment: Mystery Texts

You've come across five mysterious texts that have been encoded with a Caesar cipher. Your job is to design a program that can decode texts, so that you can then apply it to these five texts and determine where they came from.

1. Create a function, caesar(text,shift), that can shift any text by moving each character a certain number ("shift") in the ASCII table. For example, shifting "a" by 3 should change it to "d". Go ahead and convert all letters to lowercase, and you should leave all other characters alone. Be careful about wrapping letters around the end of the alphabet! Your function should return a version of the text where all characters have been shifted by shift. Here's one possible start for your function.

2. Create a second function, checker(text,shift) that will call the caesar function on the text, using the given shift, and then print out a sample of the text for the user to see. If the user recognizes the sample as valid English words, the checker function should return True. Else, it should return False.

3. Create a third function, decode(), that interacts with the user and asks them to input a textfile. The function should then cycle through all possible 26 shifts, calling your checker function on each shift until the function returns True. Note: Be sure to write your code so that the user will enter a filename instead of just a string; if you're uncomfortable with files, this is a great time to learn!

4. Call the decode() function and input each of the following encoded texts, one at a time (you'll want to right click on each and save them into the same location as your python file). Figure out what the texts say and then use internet searches to figure out where each of them are from (e.g., Declaration of Independence, script of Good Will Hunting, etc.). Once you figure them out, email me your entire python file along with your answers for where these five messages are from (that part can be in the body of the email; if you can't find it exactly, give me a brief description of what it seems to be).

Optional bonus for Step 3: Call your letters function (cut and paste your letters function into this same file!) on the textfile to figure out which letters are most frequently used in the textfile. Your decode program will then try to match these frequently used letters with the shift needed to take them back to an "e". It will test, in order, the best possible matches by using the checker function

INCLUDE OPTIONAL BONUS IF POSSIBLE

MUST BE DONE THROUGH PYTHON AND BE ABLE TO COPY AND PASTE PERFECTLY

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions