Morse code Your code for this problem should go in a file called MorseCode.py. Morse code...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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). 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).
Expert Answer:
Posted Date:
Students also viewed these programming questions
-
Jane Doe is single and claims 2 withholding allowances. If her weekly gross earning is $1,450, then determine the Federal Withholding Tax.
-
Note that in cylindrical upsetting, the frictional stress cannot be greater than the shear yield stress k, of the material. Thus, there may be a distance x in Fig. 6.8 where a transition occurs from...
-
Derive Eq. (12-43b). Equation (12-43) 4VRT 8.586VT Dia tray column Approximate 1.37 P
-
Managements responsibility for the entitys compliance with compliance requirements includes the following: (a) Identifying the entitys government programs and understanding and complying with the...
-
Carter-Pierce Investments specializes in low-risk government bonds. Identify each of Carter-Pierces transactions as operating (O), investing (I), financing (F), non-cash investing and financing...
-
Impaired Goodwill and Amortization of Patent On April 1, apatent with an estimated useful economic life of 12 years wasacquired for $57,600. In addition, on December 31, it was estimatedthat goodwi 2...
-
According to the lecture in the course, which one of the following is not one of the six reasons for Profit Concerns? a. Profit is a source of reward for the company shareholders. b. Profit plays a...
-
Bupco wants an improvement in collections as well, but the managers are peaceful souls and are leery of hiring Big Jin. They are considering a more positive approach-changing their credit policy from...
-
In preparing its financial statements for December 31, 2011, Razmataz Company reported the following information: Item Amount Gain on sale of equipment Proceeds from Sale of Equipment ($6,000)...
-
A student is walking in the university campus when it starts snowing. She holds an umbella at an angle of 27^0 with vertical in forward direction to protect her from snow fall. If snow is falling...
-
How do implicit biases and cognitive schemas influence the formation and evolution of organizational subcultures, and what measures can be implemented to promote inclusivity and equity within such...
-
If Rainbow Manufacturing has actual monthly sales of $2,100,000 and desires an operating profit of $75,000 per month, what is the margin of safety in sales dollars?
-
Ted (69) and Sharon (67) are married and will file a joint return. During the year, Ted received $9,000 in social security benefits, and Sharon received $28,000 in benefits. In addition, the couple...
-
What types of questions can be answered by analyzing financial statements?
-
NBC has the rights to televise the Winter Olympics in two years, and is trying to estimate the value of these rights for possible sale to another network. NBC expects it to cost \($40\) million (in...
-
Cyclops Inc., a high-technology company specializing in state-of-theart visual technology, is considering going public. While the company has no revenues or profits yet on its products, it has a...
-
You have been asked to analyze the value of an oil company with substantial oil reserves. The estimated reserves amount to 10 million barrels, and the estimated cost of developing these reserves...
Study smarter with the SolutionInn App