odule to do the translation. 1. Download the morse module to your folder. 2. Create your step_1.py program and import morse --> morse.py Download morse.py 3. Create your menu driven interface using a while loop with the following menu:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Here is step one in  my python project

In this step we'll be translating a single letter to Morse Code and a single Morse Code to a letter. The only input validation will be on the menu selection to handle the case where the user has entered something other than 0, 1 or 2. We'll import a module of our own (provided for you) and we'll use the dictionaries in that module to do the translation.

1. Download the morse module to your folder.

2. Create your step_1.py program and import morse --> morse.py Download morse.py

3. Create your menu driven interface using a while loop with the following menu:


    Morse Code Translator
    
    0: Exit
    1: Translate a word into Morse Code
    2: Translate Morse Code to text.

4. Use an if-elif-else construct, with 'else' explaining to the user that the selection was invalid and that only 0, 1 and 2 are acceptable inputs.

5. If the user enters "0", exit the program.

6. If the user enters "1":

  1. Prompt the user for a letter with the input() command and convert it to upper case with the upper() string method.
  2. Use that letter as a key in the alpha_to_morse dictionary (from the morse module) to fetch the Morse Code value.
  3. Display a message to the user showing the Morse Code associated with the letter provided.

7. If the user enters "2":

  1. Prompt the user for a Morse Code with the input()
  2. Use the Morse Code as a key to the morse_to_alpha dictionary (morse module) to fetch the corresponding letter value.
  3. Display a message to the user showing the letter associated with the Morse Code.

 

 

Step 2 in my python project 

 

Now that you have the while loop and the dictionary translations working, the next task is to create two functions, translate_to_morse() and translate_to_alpha().

  1. Make a copy of step_1. py and save it as step_2.py, as a starting point.
  2. At the top of the program, underneath the header comments, create both functions. translate_to_morse() should have one parameter, a string which consists of a letter. Move the code used in Menu Selection 1 to translate the letter to a Morse Code into the function. Put the resulting Morse Code into the return statement.
  3. In the same fashion, create the translate_to_alpha() function and move the translation code from the while loop into the function. Note that the parameter for translate_to_alpha() is a Morse Code, not a letter.
  4. In Menu Selection 1, call the translate_to_morse() function, passing the letter as an argument and storing the return value in a variable. Both the input() and print() statements from Step 1 should remain inside the while loop an should NOT be part of the function. The function's job is to do the translation, not to communicate with the user.
  5. The changes to Menu Selection 2 are basically the same. Call the translate_to_alpha() function, passing the Morse Code as an argument and storing the return value in a variable. Similarly, the input() and print() statements should not be part of the function.

Note that for testing purposes, you can take the output of Menu Selection 1 and copy-and-paste it as input to Menu Selection 2 and the result should be the results should mirror each other. That is, entering "S" for Menu Selection 1 should result in "..." as a Morse Code. Use this as input for Menu Selection 2 and the result should be "S".

 

Here's the code I have for step one in the python on project

 

def morse_code(text):
 tranlation_dic = {
  "A": ".-",
  "B": "-...",
  "C": "-.-.",
  "D": "-..",
  "E": ".",
  "F": "..-.",
  "G": "--.",
  "H": "....",
  "I": "..",
  "J": ".---",
  "K": "-.-",
  "L": ".-..",
  "M": "--",
  "N": "-.",
  "O": "---",
  "P": ".--.",
  "Q": "--.-",
  "R": ".-.",
  "S": "...",
  "T": "-",
  "U": "..-",
  "V": "...-",
  "W": ".--",
  "X": "-..-",
  "Y": "-.--",
  "Z": "--..",
  ".-": "A",
  "-...": "B",
  "-.-.": "C",
  "-..": "D",
  ".": "E",
  "..-.": "F",
  "--.": "G",
  "....": "H",
  "..": "I",
  ".---": "J",
  "-.-": "K",
  ".-..": "L",
  "--": "M",
  "-.": "N",
  "---": "O",
  ".--.": "P",
  "--.-": "Q",
  ".-.": "R",
  "...": "S",
  "-": "T",
  "..-": "U",
  "...-": "V",
  ".--": "W",
  "-..-": "X",
  "-.--": "Y",
  "--..": "Z"
 }
 return tranlation_dic[text]


menu = """
Morse Code Translator

0: Exit
1: Translate a word into Morse Code
2: Translate Morse Code to text.

"""

done = False

while not done:

 print(menu)

 selection = input('Please make a selection: ')

 if selection == "0":
  done = True

 elif selection == "1":

  morseCode = input('Please enter a word to be translated to Morse Code: ')
  morseCode = morseCode.upper()
  print("Morse Code for the provided letter is: ", morse_code(morseCode))

 elif selection == "2":

  morseCode = input('Please enter a word from the Morse Code Tranlator menu: ')
  print("Text for the provided Morse Code is: ", morse_code(morseCode))

 else:
  print("Selection is invalid. Only 0, 1, and 2 are the acceptable inputs.")
  

 

Please help me with step 2 on python project. 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY