Skip to content

Commit ef65ceb

Browse files
committed
Completed
1 parent 00e29a6 commit ef65ceb

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed

Morse_Code/image.png

23.1 KB
Loading

Morse_Code/morse.py

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import pyperclip
2+
# Required constants
3+
normal_word=["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",
4+
"0","1","2","3","4","5","6","7","8","9"]
5+
6+
morse_code=[".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--..",
7+
"-----",".----","..---","...--","....-",".....","-....","--...","---..","----."]
8+
def option_menu():
9+
option=int(input("Choose 1.For Encoding and 2.For Decoding:"))
10+
if (option==1):
11+
word=input("Enter the sentence that you want to encode:").upper()
12+
coded_form=""
13+
for letter in word:
14+
if letter==" ":
15+
coded_form+="/ "
16+
else:
17+
ind=normal_word.index(letter)
18+
coded_form+=morse_code[ind]
19+
coded_form+=" "
20+
print(f"{word} in morse code is {coded_form}")
21+
pyperclip.copy(coded_form)
22+
print("Copied it to clipboard 😉")
23+
print("\n")
24+
option_menu()
25+
26+
if (option==2):
27+
decoded_form=""
28+
encode_word=input("Enter the sentence that you want to decode:")
29+
encoded_word=encode_word.split(" ")
30+
for item in encoded_word:
31+
if item.isalnum() or item.isalpha():
32+
print("Please enter valid morse code 😀")
33+
option_menu()
34+
if item=="/":
35+
decoded_form+=" "
36+
continue
37+
if item=="":
38+
continue
39+
else:
40+
ind=morse_code.index(item)
41+
decoded_form+=normal_word[ind]
42+
print(f"{encode_word} in decoded form is {decoded_form}")
43+
pyperclip.copy(decoded_form)
44+
print("Copied it to clipboard 😉")
45+
print("\n")
46+
option_menu()
47+
48+
49+
50+
option_menu()

Morse_Code/readme.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Package/Script Name
2+
3+
Morse Code
4+
-Encrypts and decrypts the message into the morse code
5+
-Also copies the converted message to clipboard
6+
7+
## Setup instructions
8+
9+
You can install these using pip install
10+
pip install -r requirements.txt
11+
12+
## Detailed explanation of script, if needed
13+
14+
15+
16+
## Output
17+
18+
19+
20+
## Author(s)
21+
22+
Name(s) of author(s)
23+
24+
## Disclaimers, if any
25+
26+
Use this section to mention if any particular disclaimer is required

Morse_Code/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pyperclip

0 commit comments

Comments
 (0)