-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmorsAlphabet.py
66 lines (62 loc) · 1.34 KB
/
morsAlphabet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from playsound import playsound
import os
import time
beep1 = os.path.abspath('beep1.wav')
beep2 = os.path.abspath('beep2.wav')
mors={
'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':'--.. ',
'1':'.---- ',
'2':'..--- ',
'3':'...-- ',
'4':'....- ',
'5':'..... ',
'6':'-.... ',
'7':'--... ',
'8':'---.. ',
'9':'----. ',
'0':'----- ',
'.':'.-.-.- ',
',':'--..-- ',
'?':'..--.. ',
' ':'/ ',}
while True:
userInput = input('write something:')
try:
for key in userInput:
morsOutput = mors[key]
for i in morsOutput:
if i == '.':
playsound(beep1)
time.sleep(0.04)
if i == '-':
playsound(beep2)
time.sleep(0.05)
continue
except KeyError as err:
print('I dont have this characteer in my dictionary.you can add if yout want.look the code it is easy to understand.')
continue