Skip to content

Instantly share code, notes, and snippets.

@xen
Created December 2, 2019 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xen/7eca70d34ca9ea965ecc32f491493d81 to your computer and use it in GitHub Desktop.
Save xen/7eca70d34ca9ea965ecc32f491493d81 to your computer and use it in GitHub Desktop.
Morse code
codes = {
"А": ".-",
"Б": "-...",
"В": ".--",
"Г": "--.",
"Д": "-..",
"Е": ".",
"Ж": "...-",
"З": "--..",
"И": "..",
"Й": ".---",
"К": "-.-",
"Л": ".-..",
"М": "--",
"Н": "-.",
"О": "---",
"П": ".--.",
"Р": ".-.",
"С": "...",
"Т": "-",
"У": "..-",
"Ф": "..-.",
"Х": "....",
"Ц": "-.-.",
"Ч": "---.",
"Ш": "----",
"Щ": "--.-",
"Ъ": "--.--",
"Ы": "-.--",
"Ь": "-..-",
"Э": "..-..",
"Ю": "..--",
"Я": ".-.-",
"1": ".----",
"2": "..---",
"3": "...--",
"4": "....-",
"5": ".....",
"6": "-....",
"7": "--...",
"8": "---..",
"9": "----.",
"0": "-----",
".": "......",
",": ".-.-.-",
":": "---...",
";": "-.-.-.",
"(": "-.--.-",
")": "-.--.-",
"'": ".----.",
'"': ".-..-.",
"-": "-....-",
"/": "-..-.",
"?": "..--..",
"!": "--..--",
"@": ".--.-.",
"=": "-...-",
" ": " ",
}
print("Перевод текста в азбуку Морзе")
text = input("Введите текст кирилицей: ")
converted = " ".join([codes[i] for i in text.upper()])
print(f"Ваш текст азбукой Морзе будет {converted}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment