Question: I need help writing this python code. 1. Prompt the user with the following menu options: e to add your English sentence to be encrypted
I need help writing this python code.
1. Prompt the user with the following menu options:
e to add your English sentence to be encrypted
r to decrypt a coded message
x to quit the program
Any other input should prompt the user with the menu again.
2. Prompt for a key: You will first need to ask the user for an encryption/decryption key (an integer from 1 to 25). For encryption, you will add this number to the ASCII value of each character in the plain text message to get the coded result; for decryption, you will subtract the key from each character of the coded message to get the plain text result.
3. Adding Strings: You will then ask the user to enter a message of variable length. Only letters (a-z, not case-sensitive) should be allowed.
4. Result: Print the resulting encrypted or decrypted message.
5. Repeat: Continue to prompt the user with the menu until x is entered.
Additional Information: 1. Try to do this in pieces: a. get the command loop working (sentinel structure) b. use conditions and loops to encrypt and decrypt your messages 2. You will be using several string manipulation techniques we have studied in class (see all your string notes). You will also need to refer to the ASCII values for letters, found on the handout from the course website (or you could look them up online). HINT: Start with an empty string as your result, then add characters to that until your encryption/decryption is finished. Print that final result.
Extra Credit (2 pts): Add input validation for the encryption/decryption key so that if a non-number is entered, the prompt for the key is repeated.
Sample Run (User input is shown in bold):
** Menu ** 'e' to add your English sentence to be encrypted 'r' to decrypt a coded message 'x' to quit Enter a command: e Enter your encryption key (1-25): 7 Enter your plain text message (letters only): This is cool
Coded message: aopz pz jvvs
** Menu ** 'e' to add your English sentence to be encrypted 'r' to decrypt a coded message 'x' to quit Enter a command: r Enter your decryption key (1-25): 7 Enter your encrypted message (letters only): aopz pz jvvs
Decrypted plain text: this is cool
** Menu ** 'e' to add your English sentence to be encrypted 'r' to decrypt a coded message 'x' to quit Enter a command: e Enter your encryption key (1-25): 8 Enter your plain text message (letters only): I am number 1 Invalid characters entered. Please enter a new menu choice.
** Menu ** 'e' to add your English sentence to be encrypted 'r' to decrypt a coded message 'x' to quit Enter a command: x
Thank for using the code machine!
Program Documentation:
Use the project header as specified in the Style Guidelines on Northwest Online.
Use good programming style.
For example, use blank lines to separate major sections of code.
Use comments to indicate the major steps in your program algorithm.
Use back slash ( \ ) character if the statement continues onto the next line and is lengthy
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
