Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

decode.py (20 points: string manipulation)In this last exercise, you are going to read in an external file that contains a coded message and de-code it!

decode.py (20 points: string manipulation)In this last exercise, you are going to read in an external file that contains a coded message and de-code it! Reading the external file is done for you, as with the last exercise. The decoding should be performed with this scheme in mind: When originally coded, each letter was transposed by adding 5 to its ASCII code, except for all lower case letters a, which were not changed. Therefore you have to figure out a way to reverse this process in order to decode. The function that you have to write, decode(lines), takes in a group of strings stored together (as in the last exercise) in an EXTERNAL FILE called message.txt, which contains a coded message that you must decipher. The function then goes through each string (line) in this list, then each character in the line, and does the decoding (on a character-by-character basis). Finally, it has to print out each line it decodes. See the example below (which does not use the file that you will be using): -bash-4.2$ cat message.txt Ymjwj,x%a%qnyyqj%gqahp%xuty%ts%ymj%xzs%ytia~3 Ny,x%ymj%xarj%tqi%ymnsl%ax%~jxyjwia~3 -bash-4.2$ -bash-4.2$ python3 decode.py There's a little black spot on the sun today. It's the same old thing as yesterday. The Linux command cat message.txt means show me whats in the file message.txt. As you see from the example, the file contains garbled (coded) text. The Python program, decode.py, if working properly, prints out the decoded text.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

2. Explain grades or test results.

Answered: 1 week ago