Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROBLEM. ROT13 (rotate by 13 places) is a simple letter substitution cipher that replaces a letter with the 13th letter after it in the alphabet.

image text in transcribedimage text in transcribed

PROBLEM. ROT13 ("rotate by 13 places") is a simple letter substitution cipher that replaces a letter with the 13th letter after it in the alphabet. ROT13 is a special case of the Caesar cipher developed in ancient Rome. R0T13 has inspired a variety of letter and word games online, and is frequently mentioned in newsgroup conversations. Applying ROT13 to a piece of text merely requires examining its alphabetic characters and shifting each one by the letter 13 places further along in the alphabet, wrapping back to the beginning if necessary. For instance, A becomes N, B becomes O, and so on up to M, which becomes Z. Then, the sequence continues at the beginning of the alphabet. That is, N becomes A, 0 becomes B, and so on to Z, which becomes M. Only those letters which occur in the English alphabet are shifted; numbers, symbols, punctuation, whitespace, and all other characters are left unchanged. Because there are 26 letters in the basic Latin alphabet, ROT13 is its own inverse. This means that, to undo ROT13, you can apply the same algorithm (this means that the same action can be used for encoding and decoding). For example, in the following joke, the punchline has been obscured by ROT13: Why did the chicken cross the road? Gb trg gb gur bgure fvqr! Transforming the entire text via ROT13 form, the answer to the joke is revealed: Jul qvq gur puvpxra pebff gur ebnq? To get to the other side! A second application of ROT13 would restore the original. TASK. Accompanying this test there are files rot13.py, main.py, and README.md. Your task is to complete and to fix the code in the files rot13.py and main.py in order to obtain a full working implementation of a ROT13 text cypher. Morever, you should include a brief description on how to use this code in the file README.md The code to complete is indicated with the keyword TODO included as a comment and requires for you to: (1) understand what a particular function does in order to write a comment; (2) determine the parameters and/or arguments of a particular function; (3) finish the definition of a function. The code to fix require you to identify and repair syntax errors. Submission. You must submit the files main.py, rot13.py, and README.md all zipped into one file. Your program must take its input from the command line. The input to your program will be two files. The first file will contain the input to which the R0T13 text cypher is meant to be applied. The second file will contain the result of applying the ROT13 text cypher to the input. This means that you should be able to execute your program by using: python3 main.py In any other case, the program should print: error: incorrect number of arguments for main.py (use: main.py ) If the input to your program consists of two files, then it is assumed that: (1) the first file contains the text to which the ROT13 is meant to be applied (line by line); (2) the second file will contain the text that will result of applying the ROT13 text cypher to each line in the input file. For instance, if the file plain.01 contains the lines: Why did the chicken cross the road? Gb trg gb gur bgure fvqr! Then, executing python3 main.py plain.01 encoded.01 should result in a file encoded.01 with the lines: Jul qvq gur puvpxra pebff gur ebnq? To get to the other side

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

Students also viewed these Databases questions