├── scrin.png ├── LICENSE ├── README.md └── morse.py /scrin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/Morse_code/HEAD/scrin.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Andrej Marinchenko 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Convert English text to Morse code and vice versa 2 | 3 | 4 | Real-time monitoring program for RAM, CPU, and hard drive usage. Written in Python with GUI support. 5 |

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |

17 | 18 | 19 | ![GUI](scrin.png) 20 | 21 | 22 | 23 | ## How to install and run 24 | ____ 25 | ### Clone the repository 26 | 27 | ```sh 28 | $ cmd 29 | $ git clone https://github.com/BEPb/Morse_code 30 | $ cd python-bot 31 | ``` 32 | 33 | ### Install the necessary packages (Install dependencies) 34 | ```sh 35 | $ -r requirements.txt 36 | ``` 37 | 38 | ## Usage 39 | In the terminal, change to the program directory: 40 | ``` 41 | $ cd Morse_code 42 | ``` 43 | and enter: 44 | ``` 45 | python3 -m morse 46 | ``` 47 | enter text or cipher for reverse morse code translation 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /morse.py: -------------------------------------------------------------------------------- 1 | """ 2 | Python 3.9 программа перевода с английского в код Морзе 3 | Название файла morse.py 4 | 5 | Version: 0.1 6 | Author: Andrej Marinchenko 7 | Date: 2022-04-15 8 | """ 9 | 10 | def morse(kata): 11 | morseAlphabet ={ 12 | "A" : ".-", "B" : "-...", 13 | "C" : "-.-.", "D" : "-..", "E" : ".", 14 | "F" : "..-.", "G" : "--.", "H" : "....", 15 | "I" : "..", "J" : ".---", "K" : "-.-", 16 | "L" : ".-..", "M" : "--", "N" : "-.", 17 | "O" : "---", "P" : ".--.", "Q" : "--.-", 18 | "R" : ".-.", "S" : "...", "T" : "-", 19 | "U" : "..-", "V" : "...-", "W" : ".--", 20 | "X" : "-..-", "Y" : "-.--", "Z" : "--..", 21 | " " : "/" 22 | } 23 | key=[] 24 | kat = kata.upper() 25 | for k in kat: 26 | key.insert(len(key), k) 27 | for a in key: 28 | i = key.index(a) 29 | key[i] = morseAlphabet[a] 30 | 31 | 32 | return " ".join(key) 33 | 34 | def reverse(m): 35 | alphabet ={ 36 | ".-": "A", "-...": "B", 37 | "-.-.":"C", "-..": "D", ".": "E", 38 | "..-.":"F", "--.": "G", "....": "H", 39 | "..": "I", ".---": "J", "-.-": "K", 40 | ".-..":"L", "--": "M", "-.": "N", 41 | "---": "O", ".--.": "P", "--.-": "Q", 42 | ".-.": "R", "...": "S", "-": "T", 43 | "..-": "U", "...-": "V", ".--": "W", 44 | "-..-":"X", "-.--": "Y", "--..": "Z", 45 | "/" :" " 46 | } 47 | kta = m.split(" ") 48 | for a in kta: 49 | i = kta.index(a) 50 | kta[i] = alphabet[a] 51 | return "".join(kta).title() 52 | 53 | 54 | while True: 55 | a = input("Enter text or cipher for reverse Morse code translation: ") 56 | if a[0] =="." or a[0] == "-": 57 | print(reverse(a)) 58 | else: 59 | print(morse(a)) 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | --------------------------------------------------------------------------------