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

Kindly help to solve homework but please do not use the existing answer on the s

ID: 3833904 • Letter: K

Question

Kindly help to solve homework but please do not use the existing answer on the site, I need my own solution. Make sure you address both part 1 and part 2 effectively

Encrypt/Decrypt part 1

For part 1, you will NOT be writing anything in Python. You will be describing how the program will work using words and illustrations if it helps.

Using a dictionary, make a text encrypter/decrypter.

In decrypt mode, if the user inputs “Y r u l8?”, the program should output “Why are you late?”, for example.

In encrypt mode, if the user inputs “See you later”, it should output “c u l8r”.

Obviously you can’t handle every possible phrase, but add as many as you can. Don’t bother with multiword shortcuts for now (LOL, BRB, etc.)

How would this work?

What do you need to do?

Make a written outline of how you would accomplish the task using english or flow diagrams. Do NOT use any Python instructions in your description.

Encrypt/Decrypt part 2

Submit your Python code that runs the Encrypt/Decrypt process described in Part 1.

Explanation / Answer

PROGRAM CODE:

# your code goes here

dict = {'c': 'see', 'l8':'late', 'l8r':'later', 'u':'you', 'r':'are', 'y':'why', 'k':'okay',
               'n8':'night', 'r8':'right', 'idk':'i dont know', 'ttyl':'talk to you later',
               'brb':'be right back', 'asap':'as soon as possible', 'aka':'also know as',
               'lol':'laugh out loud', 'rofl':'rolling on the floor laughing'}
def decrypt(message):
   decryptedMessage = "";
   words = message.split(" ")
   for i in range(0, len(words)):
       word = words[i].lower()
       punct = ""
       if(word[len(word)-1]<'a' or word[len(word)-1]<'A' and word[len(word)-1]>'z' and word[len(word)-1]>'Z'):
           punct = word[-1:]
           word = word[:-1]
           #print(word)
       if word != '':
           if dict[word] == None:
               decryptedMessage = decryptedMessage + word + punct + " "
           else:
               decryptedMessage = decryptedMessage + dict[word] + punct + " "
   return decryptedMessage;

def encrypt(message):
   encryptedMessage = ""
   words = message.split(" ")
   for i in range(0, len(words)):
       word = words[i].lower()
       punct = ""
       if(word[len(word)-1]<'a' or word[len(word)-1]<'A' and word[len(word)-1]>'z' and word[len(word)-1]>'Z'):
           punct = word[-1:]
           word = word[:-1]
       if word != '':
           done = False
           for word1, word2 in dict.items():
               if word2 == word:
                   encryptedMessage = encryptedMessage + word1 + punct + " "
                   done = True
                   break
           if done == False:
               encryptedMessage = encryptedMessage + word + punct + " "
   return encryptedMessage;

print(decrypt("c u?"))
print(encrypt("see you?"))

OUTPUT: