Morse Code Encoder

The aim of this challenge is to create a Morse code converter that lets the user enter any message. The program should then display the message in Morse code. To complete this challenge you will need to know how Morse code works. If the information given below is not clear enough you can find out more about Morse code on this wikipedia page.

Morse code is a method of transmitting text information as a series of on-off tones, lights, or clicks that can be directly understood by a skilled listener or observer without special equipment.

Each character (letter or numeral) is represented by a unique sequence of dots and dashes. The duration of a dash is three times the duration of a dot.

For this challenge we will be using the international Morse code as follows:
Morse_code

Learning Objectives


By completing this challenge we are going to learn about Python dictionaries.
In Python, a dictionary consists of pairs (called items) of keys and their corresponding values.

Python dictionaries are also known as associative arrays or hash tables. The general syntax of a dictionary is as follows:
PythonDictionary

myDictionary = {"Red": "#FF0000", "Green": "#00FF00", "Blue": "#0000FF"}
print("The colour code for Green is:")
print(myDictionary["Green"])

btnTryCodeOnline

Morse Code Encoder


Check the code below to encore your own message into Morse code:

Challenge #1:


Complete the code above to add the Morse code for number digits between 0 and 9 as follows:
Morse_code_numbers

Challenge #2: Morse Code Decoder


Write a program that enables you to decode a message written in Morse code. For instance, your program should be able to decode the following message:
… — … -.-. –.- -.. – .. – .- -. .. -.-. .– . .- .-. . … .. -. -.- .. -. –. ..-. .- … –

Challenge #3: Sending Light Signals


Morse_code_signalsCheck the following code used to simulate a lamp going on and off to reproduce an SOS call in Morse code: … — …

Combine this code with the code from the Morse code encoder to create light signals in Morse code. Remember the rules of Morse code:

  • Each character (letter or numeral) is represented by a unique sequence of dots and dashes.
  • The duration of a dash is three times the duration of a dot.
  • Each dot or dash is followed by a short silence, equal to the dot duration.
  • The letters of a word are separated by a space equal to three dots (one dash).
  • The words are separated by a space equal to seven dots.


unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 3.7 / 5. Vote count: 6

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: