#4k. Coding In Python {MORSE CODE CONVERTER}
thisdict1={".-": "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"}
thisdict2={'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':'--..'}
zabc=[]
yabc=[]
print('For morse to alphabet press 1;')
print('For alphabet to morse press 2.')
qwerty=int(input('Enter choice: '))
if qwerty==1:
aw=int(input('Enter number of words: '))
for awi in range (aw):
awn=int(input('Enter number of letters in the next word: '))
space=(' ')
zabc.append(space)
for ali in range (awn):
abc=str(input('Enter next letter in morse: '))
yabc.append(abc)
space=(' ')
zabc.append(space)
yabc.append(space)
qwd=thisdict1.get(abc)
zabc.append(qwd)
for tkz in (yabc):
print(tkz,end="")
print("")
for tkz1 in (zabc):
print(tkz1,end="")
if qwerty==2:
aw=int(input('Enter number of words: '))
for awi in range (aw):
awn=int(input('Enter number of letters in the next word: '))
space=(' ')
zabc.append(space)
yabc.append(space)
for ali in range (awn):
abc=str(input('Enter next letter : '))
space=(' ')
zabc.append(space)
yabc.append(space)
yabc.append(abc)
qwd=thisdict2.get(abc)
zabc.append(qwd)
for tkz in (yabc):
print(tkz,end="")
print("")
for tkz1 in (zabc):
print(tkz1,end="")
Get CODES here.
For online python CLICK HERE .
"-...":"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"}
thisdict2={'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':'--..'}
zabc=[]
yabc=[]
print('For morse to alphabet press 1;')
print('For alphabet to morse press 2.')
qwerty=int(input('Enter choice: '))
if qwerty==1:
aw=int(input('Enter number of words: '))
for awi in range (aw):
awn=int(input('Enter number of letters in the next word: '))
space=(' ')
zabc.append(space)
for ali in range (awn):
abc=str(input('Enter next letter in morse: '))
yabc.append(abc)
space=(' ')
zabc.append(space)
yabc.append(space)
qwd=thisdict1.get(abc)
zabc.append(qwd)
for tkz in (yabc):
print(tkz,end="")
print("")
for tkz1 in (zabc):
print(tkz1,end="")
if qwerty==2:
aw=int(input('Enter number of words: '))
for awi in range (aw):
awn=int(input('Enter number of letters in the next word: '))
space=(' ')
zabc.append(space)
yabc.append(space)
for ali in range (awn):
abc=str(input('Enter next letter : '))
space=(' ')
zabc.append(space)
yabc.append(space)
yabc.append(abc)
qwd=thisdict2.get(abc)
zabc.append(qwd)
for tkz in (yabc):
print(tkz,end="")
print("")
for tkz1 in (zabc):
print(tkz1,end="")
Get CODES here.
For online python CLICK HERE .
Comments