Write a Python program to encode the plain text message and another Python program to decode the encoded message.

Use the following as starter code:

# <Put your name here> # HW 5 Caesar Cipher: Encoder # Do not modify next 8 lines def encode():     print(“Caesar cipher”)     print()    # chars is given for your convenience. It will help for     # an easier solution. You do not have to use it.     chars = “ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz”     # Fill in the expression to ask for the key value:     key =     # Fill in the expression to ask for the phrase to encode:     plain =     # Your main code starts here. Use as many lines as needed.     # Do not modify any lines below     print(“Encoded message follows:”)     print(cipher) encode()

  • Be aware that chars is a long string having 53 characters in it. There is only one space between letters `Z’ and `a’ in it.
  • You must use an accumulator variable for the encoded message.
  • You may also want to use a for loop, the remainder operator, the string find() function to find the location of a letter from chars, string indexing and the len() function.
  • You are not allowed to use any other Python modules or functions that have not been discussed in class nor in the book.
  • Show the result using the message “The quick brown fox Alice jumps over the lazy dog Zoro” in a Jupyter Notebook cell.

2. (15 points)

Write another Python program to decode the encoded message according to the “circular Caesar cipher” problem presented in Programming Exercises 7 and 8 of Book Chapter 5.

Use the following as starter code:

# <Put your name here> # HW 5 Caesar Cipher: Decoder # Do not modify next 8 lines def decode():     print(“Caesar cipher”)     print()    # chars is given for your convenience. It will help for     # an easier solution. You do not have to use it.     chars = “ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz”     # Fill in the expression to ask for the key value:     key =     # Fill in the expression to ask for the phrase to decode:     plain =     # Your main code starts here. Use as many lines as needed.     # Do not modify any lines below     print(“Decoded message follows:”)     print(cipher) decode()

  • Use the same guidelines as given in the previous question.
  • Show the result using the encoded message from “The quick brown fox Alice jumps over the lazy dog Zoro” in a Jupyter Notebook cell.

Leave a Reply

Your email address will not be published. Required fields are marked *