Question: ''' Secret Message: AP-CSP Python Take Home Test -------- Name: Period: Create a class called Secret_Message. This class has one class variable named key_list, and
'''
Secret Message: AP-CSP Python Take Home Test
--------
Name: Period:
Create a class called Secret_Message. This class has one
class variable named key_list, and two instance variables;
an integer named stepper and a dictionary name key. It also
has two instance methods named encrypt and decrypt.
Encrypt accepts a string message argument and
returns an encrypted string. Decrypt takes an encrypted
string argument and returns the decrypted message string
value.
Before creating any instance objects from the
class, the class variable must be set equal to a randomized
list of integers between 1 and 225. When an object of
Secret_Message is instantiated, it is passed a stepper
integer of either 2, 3, or 4. This value will then be used
to create a key from the key_list by selecting 52 key values
from every 2nd, 3rd, or 4th value from the key_list. Each
value is paired in a key dictionary with the letters of the
alphabet*.
When a text string is passed to the encryt message, each
letter is encrypted as an integer by looking up its integer
equivalent in the key dictionary, saving it to a temporary
list, and then returning the completed list cast to string.
When the same string returned from the encrypt method is
passed to the decryt method, the original string should be
returned.
Be sure and test your class by creating an instance and
encrypting and decrypting a message in the interactive
window with logging turned on. The original code and the
log file must both be submitted. Code will be graded on
completion (80%), structure (10%), and use of comments (10%)
* Hint: The dictionary will require two inner/outer loop
constructs where the outer loops steps through the
values in the key_list and the inner loops pair them
with each letter of the alphabet and adds the pairs
to the dictionary.
The key should end up looking something like:
key = {'a':155, 'b':26, ... 'A':92, 'B': 54, ...}
To generate the letters of the alphabet, use:
for lowercase in range(ord('a'),ord('z')+1):
lower = chr(lowercase)
or
for uppercase in range(ord('A'),ord('Z')+1):
upper = chr(uppercase)
'''
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
