Question: Could anyone please help with this Python code? In this programming assignment, you will write a program called cipher.py that uses a cipher to encode
Could anyone please help with this Python code?
In this programming assignment, you will write a program called cipher.py that uses a cipher to encode and decode secret messages.
Cipher Rules: Use the following cipher to encode and decode your messages:
| Input | Replace with |
| a | 0 |
| b | 1 |
| c | 2 |
| d | 3 |
| e | 4 |
| f | 5 |
| g | 6 |
| h | 7 |
| i | 8 |
| j | 9 |
| k | ! |
| l | @ |
| m | # |
| n | $ |
| o | % |
| p | ^ |
| q | & |
| r | * |
| s | ( |
| t | ) |
| u | - |
| v | + |
| w | < |
| x | > |
| y | ? |
| z | = |
The program should start with a menu. It should ask the user whether they/d like to encode a message, decode a message, or exit. The following section contains sample output.
Sample Output
(Input is highlighted in orange)
Welcome to the Secret Message Encoder/Decoder 1. Encode a message 2. Decode a message 3. Exit What would you like to do? 1 Enter a message to encode: hello world Encoded message: 74@@% <%*@3
Welcome to the Secret Message Encoder/Decoder 1. Encode a message 2. Decode a message 3. Exit What would you like to do? 2 Enter a message to decode: 74@@% <%*@3 Encoded message: hello world
Welcome to the Secret Message Encoder/Decoder 1. Encode a message 2. Decode a message 3. Exit What would you like to do? 1 Enter a message to encode: this message is top secret Encoded message: )78( #4((064 8( )%^ (42*4) Welcome to the Secret Message Encoder/Decoder 1. Encode a message 2. Decode a message 3. Exit What would you like to do? 2 Enter a message to decode: )78( #4((064 8( )%^ (42*4) Encoded message: this message is top secret
Welcome to the Secret Message Encoder/Decoder 1. Encode a message 2. Decode a message 3. Exit What would you like to do? 3
Limitations
Note that the cipher rules described above do not account for uppercase characters, numbers or symbols in the users input. In other words, if you were to encode the word HELLO, you would get HELLO right back:
Example:
Welcome to the Secret Message Encoder/Decoder 1. Encode a message 2. Decode a message 3. Exit What would you like to do? 1 Enter a message to encode: HELLO Encoded message: HELLO
This is a limitation of the cipher we are using. This is not a problem that you need to account for in this assignment.
Testing
Once you have written your program, you need to test it. You should run your program and enter a variety of messages to encode and decode. Make sure to handle any errors in the menu-selection as well.
Example:
Welcome to the Secret Message Encoder/Decoder 1. Encode a message 2. Decode a message 3. Exit
What would you like to do? 0 0 is not a valid choice. What would you like to do? one Please enter a number between 1 and 3. What would you like to do? 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
