Created
October 14, 2019 06:19
-
-
Save growler/1b11bda37255c9e2de5924bd1252b76f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
морзе = { | |
'а': '.-', | |
'б': '-...', | |
'в': '.--', | |
'г': '--.', | |
'д': '-..', | |
'е': '.', | |
'ё': '.', | |
'ж': '...-', | |
'з': '--..', | |
'и': '..', | |
'й': '.---', | |
'к': '-.-', | |
'л': '.-..', | |
'м': '--', | |
'н': '-.', | |
'о': '---', | |
'п': '.--.', | |
'р': '.-.', | |
'с': '...', | |
'т': '-', | |
'у': '..-', | |
'ф': '..-.', | |
'х': '....', | |
'ц': '-.-.', | |
'ч': '---.', | |
'ш': '----', | |
'щ': '--.-', | |
'ъ': '.--.-.', | |
'ы': '-.--', | |
'ь': '-..-', | |
'э': '..-..', | |
'ю': '..--', | |
'я': '.-.-' | |
} | |
def текст_в_морзе(строка): | |
сообщение = [] | |
for символ in строка: | |
if символ in морзе: | |
сообщение.append(морзе[символ]) | |
return сообщение | |
print(текст_в_морзе("сообщение")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
алфавит = "абвгдеёжзийклмнопрстуфхцчшщьъыэюя" | |
размер = len(алфавит) | |
def код_цезаря(стр, ключ): | |
шифровка = "" | |
for символ in стр: | |
if символ in алфавит: | |
шифровка += алфавит[(алфавит.index(символ) + ключ) % размер] | |
else: | |
шифровка += символ | |
return шифровка | |
шифровка = код_цезаря("это секретное сообщение", 5) | |
print(шифровка) | |
print(код_цезаря(шифровка, -5)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment