Exercise 3: Caesar Cipher solution

$10.00

Original Work ?

Download Details:

  • Name: ex3.zip
  • Type: zip
  • Size: 53.51 KB

Category: You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (2 votes)

Create a function which will take in two string parameters and one integer parameter. Both of the string
parameters should be expected to be file names. The
function should take the text contained in the first file,
change all letters to lowercase, remove all non-letter characters, and perform a Caesar (or shift) cipher on the
remaining message. The result should be saved to the
second file name. The Caesar cipher consists of taking
each letter and shifting the letter up in the alphabet by
a given amount (e.g. b shifted by 3 is e). If a letter
should shift beyond z, it should loop back to a. The
amount shifted should be equal to the integer parameter passed in. For example, if the input file contains
Attack At Once! and the shift is 2 the output file
should contain cvvcemcvqpeg .
Hints: list(map(chr, range(97, 123))) will return a list of the 26 lowercase letters. Also, note that
on this list indexing position 3 is the same as indexing
position 29%26. Finally, if ’a’ in some_list: will
be useful to check if a character (specifically ’a’ in this
example) is in a list.
1