filmov
tv
Morse Code Encoder Decoder | Python

Показать описание
Python program to implement Morse Code Translator.
'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'
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':'-----', ', ':'--..--', '.':'.-.-.-',
'?':'..--..', '/':'-..-.', '-':'-....-',
'(':'-.--.', ')':'-.--.-'}
Stay tuned till next time.
Happy coding.
As always code is on GitHub:
Have a look at my python 21 days beginner to advance series on following Instagram handle:
'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'
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':'-----', ', ':'--..--', '.':'.-.-.-',
'?':'..--..', '/':'-..-.', '-':'-....-',
'(':'-.--.', ')':'-.--.-'}
Stay tuned till next time.
Happy coding.
As always code is on GitHub:
Have a look at my python 21 days beginner to advance series on following Instagram handle:
Комментарии