Question: Sample Output: Encode text Decode text Exit Please select an option between 1 and 3 : 1 Please enter the text to encode: My horse

Sample Output:
Encode text
Decode text
Exit
Please select an option between 1 and 3:1
Please enter the text to encode: My horse is angry. She will heart a carrot.
Encoded text: My is She will a
Encode text
Decode text
Exit
Please select an option between 1 and 3:3.1
Please select a valid option between 1 and 3.
Encode text
Decode text
Exit
Please select an option between 1 and 3:2
Please enter the text to decode: My 3 is 3?he will a
Decoded text: My horse is angry. She will heart a carrot.If after going through the whole input list, match_found is False
Add the original word at word_index to the encrypted string
Assignment 2: Secret Codes (Arrays & Functions)
Assignment for COSC 1100 Intro to Programming
Page 2 of 3
Requirements for the Cipher Functions:
In this case, we will be using a cipher to translate a message to or from emoji. A Substitution cipher is a very simple type of cipher that operates by replacing characters or words from one form of communication with those from another. In our case, we will convert from English letters into emoji. Your encode and decode functions will each have one parameter, which is the message to be translated.
English
Unicode
Emoji
English
Unicode
Emoji
English
Unicode
Emoji
100(100%)
U+1F4AF
cat
U+1F408
horse
U+1F40E
angry (mad)
U+1F620
clap
U+1F44F
map
U+1F5FA
alien
U+1F47D
cookie
cow
U+1F36A
OK (okay)
U+1F44C
apple
U+1F34E
dog
U+1F415
sad
U+1F622
banana
U+1F34C
egg
elephant
U+1F95A
sheep
(ewe)
U+1F411
bee
U+1F41D
fish
U+1F41F
sleep
(bed)
U+1F6CC
bird
U+1F426
fox
U+1F98A
tree
U+1F332
car
U+1F697
happy
U+1F600
wave
U+1F44B
carrot
U+1F955
heart
U+2764
zombie
U+1F9DF
For your assignment submission, please limit the words to translate to those included above, which were chosen intentionally by this courses professors. However, if youd like to extend things somewhat, you can include the secondary words like (mad) and (okay) that are shown in parentheses in the chart.
There are many ways to implement this in Python, but probably the easiest way for our needs would be to declare two arrays: one includes a list of words, and the other includes the emoji equivalents of those words. Then, given a message, for each word, if that word is in the first array, match that words position in the first array with the same position in the second array. Ensure that the translation happens regardless of case.
Here is some partial pseudocode for the encode function that you can make use of:
Start with an empty string called encoded_string
Use the .split() method to turn the input message into a list of words For each word_index, counting up from 0 to the length of the input word list
Assume that there is no match found (match_found = False)
For each translation_index in the emoji word list
If the word at word_index equals the input word at translation_index
Add the emoji at translation_index to the encoded_string Set match_found to True
If after going through the whole input list, match_found is False
Add the original word at word_index to the encrypted stringEven perfectly translated into Python, the output from this may not be perfect and troubleshooting the differences in how the input displays is intentionally left as an exercise.
Style Guide:
To be eligible for full marks on this or any assignment in this course your application must conform to the requirements as outlined above as well as our prescribed style guide, in this case making sure to observe the PEP8 naming conventions for Python as well as appropriate and complete program documentation.
Development Hints:
As always, start with your planning steps. The pseudocode shown above may be part of the process and plan (steps 3 and 4 of 10).
Only after planning, consider how you can translate the given pseudocode into Python code.
Ciphers are a very common programming exercise and thus there are numerous reference materials and possibly even full solutions available on the web. However, be cautious with these!
o Make sure any borrowed code works and that your program actually meets our requirements.
o Make sure all code in your program conforms to our PEP8 style guide.
o Reference any code directly taken from any form of online resource or another person, or this will be considered an incident of plagiarism. You can just do this in a comment before the part you have taken from another source.
Please make a Plan (output, input) and pseoudocode
 Sample Output: Encode text Decode text Exit Please select an option

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!