Either of two codes consisting of variously spaced dots and dashes or long and short sounds used for transmitting messages by audible or visual signals. A system of sending messages that uses long and short sounds, flashes of light, or marks to represent letters and numbers. A system of sending messages that uses long and short sounds or dots and dashes to represent letters and numbers.
The International Morse Code has, except for some minor changes in 1938, remained the same since its inception. (The American telegraph industry never abandoned the original Morse Code, and so its use continued until the spread of teleprinters in the 1920s and ’30s.) International Morse Code was used in World War II and in the Korean and Vietnam wars. It was used heavily by the shipping industry and for the safety of the seas up until the early 1990s. Although amateur radio made up only a small part of Morse Code usage, it did prepare many hundreds of operators for military duty in communications. In the early 2000s most countries had dropped the ability to decipher Morse Code from the requirements for obtaining an amateur radio license.
Morse code has been in use for more than 160 years — longer than any other electrical coding system. What is called Morse code today is actually somewhat different from what was originally developed by Vail and Morse. The Modern International Morse code, or continental code, was created by Friedrich Clemens Gerke in 1848 and initially used for telegraphy between Hamburg and Cuxhaven in Germany. Gerke changed nearly half of the alphabet and all of the numerals, providing the foundation for the modern form of the code. After some minor changes, International Morse Code was standardized at the International Telegraphy Congress in 1865 in Paris and was later made the standard by the International Telecommunication Union (ITU). Morse's original code specification, largely limited to use in the United States and Canada, became known as American Morse code or "railroad code". American Morse code is now seldom used except in historical re-enactments.
We have built a python program to translate Morse Code here is the program ..
Python program to implement Morse Code Translator
''' VARIABLE KEY 'cipher' -> 'stores the morse translated form of the english string' 'decipher' -> 'stores the english translated form of the morse string' 'citext' -> 'stores morse code of a single character' 'i' -> 'keeps count of the spaces between morse characters' 'message' -> 'stores the string to be encoded or decoded' '''
Dictionary representing the morse code chart
MORSE_CODE_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':'-----', ', ':'--..--', '.':'.-.-.-', '?':'..--..', '/':'-..-.', '-':'-....-', '(':'-.--.', ')':'-.--.-'}
Function to encrypt the string
according to the morse code chart
def encrypt(message): cipher = '' for letter in message: if letter != ' ':
# Looks up the dictionary and adds the
# correspponding morse code
# along with a space to separate
# morse codes for different characters
cipher += MORSE_CODE_DICT[letter] + ' '
else:
# 1 space indicates different characters
# and 2 indicates different words
cipher += ' '
return cipher
Function to decrypt the string
from morse to english
def decrypt(message):
# extra space added at the end to access the
# last morse code
message += ' '
decipher = ''
citext = ''
for letter in message:
# checks for space
if (letter != ' '):
# counter to keep track of space
i = 0
# storing morse code of a single character
citext += letter
# in case of space
else:
# if i = 1 that indicates a new character
i += 1
# if i = 2 that indicates a new word
if i == 2 :
# adding space to separate words
decipher += ' '
else:
# accessing the keys using their values (reverse of encryption)
decipher += list(MORSE_CODE_DICT.keys())[list(MORSE_CODE_DICT
.values()).index(citext)]
citext = ''
return decipher
Hard-coded driver function to run the program
def main(): message = "GEEKS-FOR-GEEKS" result = encrypt(message.upper()) print (result)
message = "--. . . -.- ... -....- ..-. --- .-. -....- --. . . -.- ... "
result = decrypt(message)
print (result)
Executes the main function
if name == 'main': main()
Here we learn about Morse Codes
Log in or sign up for Devpost to join the conversation.