Untitled
unknown
plain_text
3 years ago
11 kB
3
Indexable
Never
while True: tr = input('Введите "1", чтобы программа перевела морзянку на русский, введите "0", ' 'чтобы перевести русский на азбуку морзе.\n>>>') if not(tr == '1' or tr == '0'): continue else: tr = int(tr) break if tr == 0: text = input('Введите русский текст (нижний регистр) для перевода на морзу\n>>>') cn = text.count('.') while cn != 0: text = text.replace('.', '{......}') cn = cn - 1 cn = text.count('-') while cn != 0: text = text.replace('-', '{_...._}') cn = cn - 1 cn = text.count('а') while cn != 0: text = text.replace('а', '{._}') cn = cn - 1 cn = text.count('б') while cn != 0: text = text.replace('б', '{_...}') cn = cn - 1 cn = text.count('в') while cn != 0: text = text.replace('в', '{.__}') cn = cn - 1 cn = text.count('г') while cn != 0: text = text.replace('г', '{__.}') cn = cn - 1 cn = text.count('д') while cn != 0: text = text.replace('д', '{_..}') cn = cn - 1 cn = text.count('е') while cn != 0: text = text.replace('е', '{.}') cn = cn - 1 cn = text.count('ё') while cn != 0: text = text.replace('ё', '{.}') cn = cn - 1 cn = text.count('ж') while cn != 0: text = text.replace('ж', '{..._}') cn = cn - 1 cn = text.count('з') while cn != 0: text = text.replace('з', '{__..}') cn = cn - 1 cn = text.count('и') while cn != 0: text = text.replace('и', '{..}') cn = cn - 1 cn = text.count('й') while cn != 0: text = text.replace('й', '{.___}') cn = cn - 1 cn = text.count('к') while cn != 0: text = text.replace('к', '{_._}') cn = cn - 1 cn = text.count('л') while cn != 0: text = text.replace('л', '{._..}') cn = cn - 1 cn = text.count('м') while cn != 0: text = text.replace('м', '{__}') cn = cn - 1 cn = text.count('н') while cn != 0: text = text.replace('н', '{_.}') cn = cn - 1 cn = text.count('о') while cn != 0: text = text.replace('о', '{___}') cn = cn - 1 cn = text.count('п') while cn != 0: text = text.replace('п', '{.__.}') cn = cn - 1 cn = text.count('р') while cn != 0: text = text.replace('р', '{._.}') cn = cn - 1 cn = text.count('с') while cn != 0: text = text.replace('с', '{...}') cn = cn - 1 cn = text.count('т') while cn != 0: text = text.replace('т', '{_}') cn = cn - 1 cn = text.count('у') while cn != 0: text = text.replace('у', '{.._}') cn = cn - 1 cn = text.count('ф') while cn != 0: text = text.replace('ф', '{.._.}') cn = cn - 1 cn = text.count('х') while cn != 0: text = text.replace('х', '{....}') cn = cn - 1 cn = text.count('ц') while cn != 0: text = text.replace('ц', '{_._.}') cn = cn - 1 cn = text.count('ч') while cn != 0: text = text.replace('ч', '{___.}') cn = cn - 1 cn = text.count('ш') while cn != 0: text = text.replace('ш', '{____}') cn = cn - 1 cn = text.count('щ') while cn != 0: text = text.replace('щ', '{__._}') cn = cn - 1 cn = text.count('ь') while cn != 0: text = text.replace('ь', '{_.._}') cn = cn - 1 cn = text.count('ъ') while cn != 0: text = text.replace('ъ', '{_.._}') cn = cn - 1 cn = text.count('ы') while cn != 0: text = text.replace('ы', '{_.__}') cn = cn - 1 cn = text.count('э') while cn != 0: text = text.replace('э', '{.._..}') cn = cn - 1 cn = text.count('ю') while cn != 0: text = text.replace('ю', '{..__}') cn = cn - 1 cn = text.count('я') while cn != 0: text = text.replace('я', '{._._}') cn = cn - 1 cn = text.count('1') while cn != 0: text = text.replace('1', '{.____}') cn = cn - 1 cn = text.count('2') while cn != 0: text = text.replace('2', '{..___}') cn = cn - 1 cn = text.count('3') while cn != 0: text = text.replace('3', '{...__}') cn = cn - 1 cn = text.count('4') while cn != 0: text = text.replace('4', '{...._}') cn = cn - 1 cn = text.count('5') while cn != 0: text = text.replace('5', '{.....}') cn = cn - 1 cn = text.count('6') while cn != 0: text = text.replace('6', '{_....}') cn = cn - 1 cn = text.count('7') while cn != 0: text = text.replace('7', '{__...}') cn = cn - 1 cn = text.count('8') while cn != 0: text = text.replace('8', '{___..}') cn = cn - 1 cn = text.count('9') while cn != 0: text = text.replace('9', '{____.}') cn = cn - 1 cn = text.count('0') while cn != 0: text = text.replace('0', '{_____}') cn = cn - 1 cn = text.count(',') while cn != 0: text = text.replace(',', '{._._._}') cn = cn - 1 cn = text.count('!') while cn != 0: text = text.replace('!', '{__..__}') cn = cn - 1 print(text) elif tr == 1: text = input('Введите текст на азбуке морзе(используя квадратные скобки "[]" или фигурные скобки"{}")\n>>>') cn = text.count('{......}') while cn != 0: text.replace('{......}', '.') cn = cn - 1 cn = text.count('{_...._}') while cn != 0: text = text.replace('{_...._}', '-') cn = cn - 1 cn = text.count('[') while cn != 0: text = text.replace('[', '{') cn = cn - 1 cn = text.count(']') while cn != 0: text = text.replace(']', '}') cn = cn - 1 cn = text.count('{._}') while cn != 0: text = text.replace('{._}', 'а') cn = cn - 1 cn = text.count('{_...}') while cn != 0: text = text.replace('{_...}', 'б') cn = cn - 1 cn = text.count('{.__}') while cn != 0: text = text.replace('{.__}', 'в') cn = cn - 1 cn = text.count('{__.}') while cn != 0: text = text.replace('{__.}', 'г') cn = cn - 1 cn = text.count('{_..}') while cn != 0: text = text.replace('{_..}', 'д') cn = cn - 1 cn = text.count('{.}') while cn != 0: text = text.replace('{.}', 'е') cn = cn - 1 cn = text.count('{..._}') while cn != 0: text = text.replace('{..._}', 'ж') cn = cn - 1 cn = text.count('{__..}') while cn != 0: text = text.replace('{__..}', 'з') cn = cn - 1 cn = text.count('{..}') while cn != 0: text = text.replace('{..}', 'и') cn = cn - 1 cn = text.count('{.___}') while cn != 0: text = text.replace('{.___}', 'й') cn = cn - 1 cn = text.count('{_._}') while cn != 0: text = text.replace('{_._}', 'к') cn = cn - 1 cn = text.count('{._..}') while cn != 0: text = text.replace('{._..}', 'л') cn = cn - 1 cn = text.count('{_.}') while cn != 0: text = text.replace('{_.}', 'н') cn = cn - 1 cn = text.count('{___}') while cn != 0: text = text.replace('{___}', 'о') cn = cn - 1 cn = text.count('{.__.}') while cn != 0: text = text.replace('{.__.}', 'п') cn = cn - 1 cn = text.count('{._.}') while cn != 0: text = text.replace('{._.}', 'р') cn = cn - 1 cn = text.count('{...}') while cn != 0: text = text.replace('{...}', 'с') cn = cn - 1 cn = text.count('{_}') while cn != 0: text = text.replace('{_}', 'т') cn = cn - 1 cn = text.count('{.._}') while cn != 0: text = text.replace('{.._}', 'у') cn = cn - 1 cn = text.count('{.._.}') while cn != 0: text = text.replace('{.._.}', 'ф') cn = cn - 1 cn = text.count('{....}') while cn != 0: text = text.replace('{....}', 'х') cn = cn - 1 cn = text.count('{_._.}') while cn != 0: text = text.replace('{_._.}', 'ц') cn = cn - 1 cn = text.count('{___.}') while cn != 0: text = text.replace('{___.}', 'ч') cn = cn - 1 cn = text.count('{____}') while cn != 0: text = text.replace('{____}', 'ш') cn = cn - 1 cn = text.count('{__._}') while cn != 0: text = text.replace('{__._}', 'щ') cn = cn - 1 cn = text.count('{_.._}') while cn != 0: text = text.replace('{_.._}', 'ь') cn = cn - 1 cn = text.count('{_.__}') while cn != 0: text = text.replace('{_.__}', 'ы') cn = cn - 1 cn = text.count('{.._..}') while cn != 0: text = text.replace('{.._..}', 'э') cn = cn - 1 cn = text.count('{..__}') while cn != 0: text = text.replace('{..__}', 'ю') cn = cn - 1 cn = text.count('{._._}') while cn != 0: text = text.replace('{._._}', 'я') cn = cn - 1 cn = text.count('{.____}') while cn != 0: text = text.replace('{.____}', '1') cn = cn - 1 cn = text.count('{..___}') while cn != 0: text = text.replace('{..___}', '2') cn = cn - 1 cn = text.count('{...__}') while cn != 0: text = text.replace('{...__}', '3') cn = cn - 1 cn = text.count('{...._}') while cn != 0: text = text.replace('{...._}', '4') cn = cn - 1 cn = text.count('{.....}') while cn != 0: text = text.replace('{.....}', '5') cn = cn - 1 cn = text.count('{_....}') while cn != 0: text = text.replace('{_....}', '6') cn = cn - 1 cn = text.count('{__...}') while cn != 0: text = text.replace('{__...}', '7') cn = cn - 1 cn = text.count('{___..}') while cn != 0: text = text.replace('{___..}', '8') cn = cn - 1 cn = text.count('{____.}') while cn != 0: text = text.replace('{____.}', '9') cn = cn - 1 cn = text.count('{_____}') while cn != 0: text = text.replace('{_____}', '0') cn = cn - 1 cn = text.count('{._._._}') while cn != 0: text = text.replace('{._._._}', ',') cn = cn - 1 cn = text.count('{__..__}') while cn != 0: text = text.replace('{__..__}', '!') cn = cn - 1 print(text)