Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Morse code Your code for this problem should go in a file called MorseCode.py. Morse code is a technique for sending messages using short
Morse code Your code for this problem should go in a file called MorseCode.py. Morse code is a technique for sending messages using short and long sounds like dots "." and dashes "-". Here is the code in a Python dictionary, where the keys are letters and the values are the corresponding Morse codes. morsecode('a': 'h' 'j': 'k': For example, the Morse code for 'a boy' is '.- We will adopt the convention that in the Morse code output there is always a space between two letters and there are three spaces between words. Write a function called morse (mystring, code) that takes as input a string and a dictionary (e.g., the Morse code dictionary above), and returns the Morse code version of that string. You can cut-and-paste the dictionary above into your function. For example: >>> morse('a boy', morsecode) Reverse translation Your code for this problem should go in a file called Reverse Translation.py. Imagine that you have a dictionary that allows you to translate from one language A to another language B and you would like to construct a reverse dictionary from B to A. For example, here is a dictionary called TE that translates from "Teenager English" to real English: TE = {'dude!' : 'hello', 'later' : 'goodbye', 'stoked' : 'happy', 'ciao': 'good With this dictionary, we can make queries such as: >>> TE['dude!'] 'hello' Your job is to write a function called reverse (D) that takes as input a Python dictionary D (such as the one above, but it could be a different one) and returns back a new dictionary that provides the inverse definitions (in this example, providing us with a way to convert from real English to "Teenager" English). Here's an example of reverse in action: >>> ET reverse (TE) >>> ET => ('hello': 'dude!', 'goodbye': 'ciao or later', 'happy': 'stoked'} >>> ET['goodbye'] 'ciao or later' Notice that since both "ciao" and "later" translate to "goodbye" in the input dictionary, the resulting output dictionary has the value 'ciao or later' associated with the 'goodbye' key. In general, the word "or" is used as the connector between all the words with the same meaning. You may assume that the input dictionary will NOT have "ors" in its values (word definitions).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started