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

In python, I need to use this dictionary: {\'a\':\'0\',\'A\':\'1\',\'0\':\'2\',\

ID: 3747011 • Letter: I

Question

In python, I need to use this dictionary:


{'a':'0','A':'1','0':'2','b':'3','B':'4','1':'5','c':'6','C':'7','2':'8','d':'9','D':'10','3':'11','e':'12','E':'13','4':'14','f':'15','F':'16','5':'17','g':'18','G':'19','6':'20',
'h':'21','H':'22','7':'23','i':'24','I':'25','8':'26','j':'27','J':'28','9':'29','k':'30','K':'31',' ':'32','l':'33','L':'34',',':'35','m':'36','M':'37','.':'38','n':'39','N':'40',
'?':'41','o':'42','O':'43','/':'44','p':'45','P':'46',';':'47','q':'48','Q':'49',':':'50','r':'51','R':'52',"'":'53','s':'54','S':'55','"':'56','t':'57','T':'58','!':'59','u':'60',
'U':'61','@':'62','v':'63','V':'64','$':'65','w':'66','W':'67','%':'68','x':'69','X':'70','&':'71','y':'72','Y':'73','-':'74','z':'75','Z':'76','=':'77'}

To encrypt or decrypt a user .txt file with a user specified shift amount.

Explanation / Answer

d = {'a': '0', 'A': '1', '0': '2', 'b': '3', 'B': '4', '1': '5', 'c': '6', 'C': '7', '2': '8', 'd': '9', 'D': '10', '3': '11', 'e': '12', 'E': '13', '4': '14', 'f': '15', 'F': '16', '5': '17', 'g': '18', 'G': '19', '6': '20', 'h': '21', 'H': '22', '7': '23', 'i': '24', 'I': '25', '8': '26', 'j': '27', 'J': '28', '9': '29', 'k': '30', 'K': '31', ' ': '32', 'l': '33', 'L': '34', ',': '35', 'm': '36', 'M': '37', '.': '38', 'n': '39', 'N': '40', '?': '41', 'o': '42', 'O': '43', '/': '44', 'p': '45', 'P': '46', ';': '47', 'q': '48', 'Q': '49', ':': '50', 'r': '51', 'R': '52', "'": '53', 's': '54', 'S': '55', '"': '56', 't': '57', 'T': '58', '!': '59', 'u': '60', 'U': '61', '@': '62', 'v': '63', 'V': '64', '$': '65', 'w': '66', 'W': '67', '%': '68', 'x': '69', 'X': '70', '&': '71', 'y': '72', 'Y': '73', '-': '74', 'z': '75', 'Z': '76', '=': '77'} filename = input('Enter file name to encrypt: ') with open(filename, 'r') as f: for line in f: encrypted_line = '' for ch in line.strip(): encrypted_line += d[ch] print(encrypted_line) filename = input('Enter file name to decrypt: ') with open(filename, 'r') as f: for line in f: decrypted_line = '' for ch in line.strip(): key = None for k, v in d.items(): if ch == v: key = k break if key is not None: decrypted_line += key print(decrypted_line)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote