Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

text file: https://www.dropbox.com/s/a25gcylrcjiqzi6/text.txt?dl=0 in python Wri

ID: 3721858 • Letter: T

Question

text file: https://www.dropbox.com/s/a25gcylrcjiqzi6/text.txt?dl=0

in python

Write a programthat uses a dictionary to assign “codes” to each letter of the alphabet. For example:

CODE = {'A':')','a':'0','B':'(','b':'9','C':'*','c':'8',

        'D':'&','d':'7','E':'^','e':'6','F':'%','f':'5',

        'G':'$','g':'4','H':'#','h':'3','I':'@','i':'2',

        'J':'!','j':'1','K':'Z','k':'z','L':'Y','l':'y',

        'M':'X','m':'x','N':'W','n':'w','O':'V','o':'v',

        'P':'U','p':'u','Q':'T','q':'t','R':'S','r':'s',

        'S':'R','s':'r','T':'Q','t':'q','U':'P','u':'p',

        'V':'O','v':'o','W':'N','w':'n','X':'M','x':'m',

        'Y':'L','y':'l','Z':'K','z':'k','!':'J','1':'j',

        '@':'I','2':'i','#':'H','3':'h','$':'G','4':'g',

        '%':'F','5':'f','^':'E','6':'e','&':'D','7':'d',

        '*':'C','8':'c','(':'B','9':'b',')':'A','0':'a',

        ':':',',',':':','?':'.','.':'?','<':'>','>':'<',

        "'":'"','"':"'",'+':'-','-':'+','=':';',';':'=',

        '{':'[','[':'{','}':']',']':'}'}

Using this example, the letter A would be assigned the symbol %, the letter

a would be assigned the number 9, the letter B would be assigned the symbol @, and so forth. The program should open a specified text file, read its contents, and then use the dictionary to write an encrypted version of the file’s contents to a second file. Each character in the second file should contain the code for the corresponding character in the first file.

Write a second program that opens an encrypted file and displays its decrypted contents on the

screen.

Explanation / Answer

Here is code for encryption

Encrypted output:

And code for decryption

Decrypted output