Title: Message Encryptor/Decryptor

Topic: Inverse Functions

Difficulty:

Required Skills: Variable assignment, for loops,  ASCII characters

Language: Python

Students can create a message encryptor and decoder. This gives them an opportunity to investigate and apply their knowledge of inverse functions.

message = "I love bananas. Monkeys love bananas. Therefore I also love monkeys."
encrypted_message
= ""
decrypted_message
= ""

for letter in message:
   x
= ord(letter)
   new_val
= x+4
   encrypted_message
= encrypted_message + chr(new_val)

print(encrypted_message)

for letter in encrypted_message:
   x
= ord(letter)
   new_val
= x-4
   decrypted_message
= decrypted_message + chr(new_val)

print(decrypted_message)