Question

Write a function that takes a sentence as a parameter and translates it into a Morse...

Write a function that takes a sentence as a parameter and translates it into a Morse code message in Python. The Morse coded message should be displayed at the console in one continuous line, each Morse code sequence should be delimited by space.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Z- , Q:: DICT = { A:.-, C:-.., D:-.., E: F:..., G:.-., H: I:.., ij:.---,K: M:. O

Code for copying

DICT = { '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':'--..',
                    '1':'.----', '2':'..---', '3':'...--',
                    '4':'....-', '5':'.....', '6':'-....',
                    '7':'--...', '8':'---..', '9':'----.',
                    '0':'-----', ', ':'--..--', '.':'.-.-.-',
                    '?':'..--..', '/':'-..-.', '-':'-....-',
                    '(':'-.--.', ')':'-.--.-'}
string=str(input("Enter the sentence : "))
encrypted=''
j=string.upper()
for i in j:
    if i != ' ':
        encrypted+=DICT[i]+' '
    else:
        encrypted+=' '
print(encrypted)       

Add a comment
Know the answer?
Add Answer to:
Write a function that takes a sentence as a parameter and translates it into a Morse...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Program Description: A C# app is to be created to produce Morse code. The Morse code...

    Program Description: A C# app is to be created to produce Morse code. The Morse code assigns a series of dots and dashes to each letter of the alphabet, each digit, and a few special characters (such as period, comma, colon, and semicolon). In sound-oriented systems, the dot represents a short sound and the dash represents a long sound. Separation between words is indicated by a space, or, quite simply, the absence of a dot or dash. In a sound-oriented...

  • Program Description: A Java program is to be created to produce Morse code. The Morse code...

    Program Description: A Java program is to be created to produce Morse code. The Morse code assigns a series of dots and dashes to each letter of the alphabet, each digit, and a few special characters (such as period, comma, colon, and semicolon). In sound-oriented systems, the dot represents a short sound and the dash represents a long sound. Separation between words is indicated by a space, or, quite simply, the absence of a dot or dash. In a sound-oriented...

  • Write a python function named displayFizzBuzz that takes a number as a parameter and DISPLAYS the...

    Write a python function named displayFizzBuzz that takes a number as a parameter and DISPLAYS the appropriate FizzBuzz value for that number. Test this function on all of the numbers between 1 and 100000. Submit the code and a screenshot of the program running in Linux

  • Python code define a function car that takes 'swift' as a parameter function should count how...

    Python code define a function car that takes 'swift' as a parameter function should count how many letters in the string function should return a dictionary where key is lower case alpha caracter and value is the number of times that character appears in sentence. ex- input- that big car is so expensive output- 't':1, 'h':1, 'a':2, 'b':1, 'i':3,......

  • Write a python function that takes a binary tree as its only parameter. Return the value...

    Write a python function that takes a binary tree as its only parameter. Return the value stored in the shallowest leaf, anywhere in the tree. If there is a tie, then return the "leftmost" of the leaves (that is, the one that you would encounter first in an in-order traversal). You are allowed (and encouraged) to use a helper function. You may assume that the tree nodes have public fields left,right. The code cannot import anything from the Python standard...

  • Please write code using Python. Rubric Assignment Solution Total: 100 pts Program successfully retrieves and validates...

    Please write code using Python. Rubric Assignment Solution Total: 100 pts Program successfully retrieves and validates user input 15 pts Morse Code Function Created 10 pts Function Uses Parameters to get input message 15 pts Function successfully converts passed message to Morse Code and returns the Morse Code equivalent of message 45 pts Program calls Morse Code function and outputs the result of the function (i.e. the actual Morse Code) 15 pts Main Function Requirement Part 2 MUST have a...

  • Python Write a function list_copy(l) that takes a list as a parameter and returns a copy...

    Python Write a function list_copy(l) that takes a list as a parameter and returns a copy of the list using a list comprehension. please provide unittest

  • PYTHON PLEASE Write a function to censor words from a sentence code: def censor_words(sentence, list_of_words): """...

    PYTHON PLEASE Write a function to censor words from a sentence code: def censor_words(sentence, list_of_words): """ The function takes a sentence and a list of words as input. The output is the sentence after censoring all the matching words in the sentence. Censoring is done by replacing each character in the censored word with a * sign. For example, the sentence "hello yes no", if we censor the word yes, will become "hello *** no" Note: do not censor the...

  • Write a Scheme function DEL-LELEMENT that takes a list as a parameter and returns a list...

    Write a Scheme function DEL-LELEMENT that takes a list as a parameter and returns a list identical to the parameter except the last element has been deleted. For example, (DEL-LELEMENT '(8 2 3 7 6)) should return (8 2 3 7) *Please explain your code and submit the source code. Please test the function with the provided example and submit a screen shot of the testing result.

  • Write a Python function named print_nums that takes a single parameter, a list of float values,...

    Write a Python function named print_nums that takes a single parameter, a list of float values, and prints out the list on a single line.enclosed in brackets, each value with three places after the decimal point, the values separated by two spaces. You do not have to provide comments for this code. Example 1: print_nums([3/3, 4/3, 573, 6/3]) prints: [1.000 1.333 1.667 2.000] Example 2: print_nums([3]) prints: [3.000] Example 3: print_nums([]) prints: []

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT