Login Register


Morse Decoder filter_list
Author
Message
Morse Decoder #1
[Image: A3kJLJb.png]


This is a very simple python program that uses a dictionary containing Morse code key like '-' for T. The condition to decode via key present in the dictionary is:

Code:
store = '' for items in code: if the key is in the dictionary: then store the value of the key in the variable Store if else the key is not found in the dictionary: print that the key was not found print value of the variable store

Source Code:

Code:
morse = {'.-' : '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', '-----' : '0', '.----':'1','..---':'2','...--':'3','....-':'4','.....':'5','-....':'6','--...':'7','---..':'8','----.':'9',} store = '' # We need to store the code with the spaces in between as intact so we use split() to keep the spaces between the codes and make a list code. code = input('Input your Morse Code: ').split() #For Error management try: #For each item in the list 'code' for item in code: #Get the value of the key and store it in the variable 'store', if the key exists in the dictionary, if not morse[item] #will be false and it will raise the KeyError that key not found in the dictionary which will be handled #as a normal error at the end of the code. store = store + morse[item] #Prints the decoded code stored in the variable 'store' print('Your Decoded Message is: %s' % store) # In case of the above code returns false due to morse[item] except KeyError as error: #Display error print('Your code contains invalid morse code character', error)

Compiled Source Download: http://www.mediafire.com/?nujm7sgcxcliu97
Everything is explained in the code comments, Have fun!
If you like, you can make it encode the normal text into a morse, you just need to reverse the dictionary values and then ask for normal text Smile
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply

Morse Decoder #2
[Image: A3kJLJb.png]


This is a very simple python program that uses a dictionary containing Morse code key like '-' for T. The condition to decode via key present in the dictionary is:

Code:
store = '' for items in code: if the key is in the dictionary: then store the value of the key in the variable Store if else the key is not found in the dictionary: print that the key was not found print value of the variable store

Source Code:

Code:
morse = {'.-' : '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', '-----' : '0', '.----':'1','..---':'2','...--':'3','....-':'4','.....':'5','-....':'6','--...':'7','---..':'8','----.':'9',} store = '' # We need to store the code with the spaces in between as intact so we use split() to keep the spaces between the codes and make a list code. code = input('Input your Morse Code: ').split() #For Error management try: #For each item in the list 'code' for item in code: #Get the value of the key and store it in the variable 'store', if the key exists in the dictionary, if not morse[item] #will be false and it will raise the KeyError that key not found in the dictionary which will be handled #as a normal error at the end of the code. store = store + morse[item] #Prints the decoded code stored in the variable 'store' print('Your Decoded Message is: %s' % store) # In case of the above code returns false due to morse[item] except KeyError as error: #Display error print('Your code contains invalid morse code character', error)

Compiled Source Download: http://www.mediafire.com/?nujm7sgcxcliu97
Everything is explained in the code comments, Have fun!
If you like, you can make it encode the normal text into a morse, you just need to reverse the dictionary values and then ask for normal text Smile
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply

RE: Morse Decoder #3
Well done, @Ex094.
I thought lately that we could make a multi encoder for HC that includes morse code as well.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: Morse Decoder #4
Well done, @Ex094.
I thought lately that we could make a multi encoder for HC that includes morse code as well.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: Morse Decoder #5
Wow that looks good , I think I am going to make one in C++ or in VB.NET too . Seeing this I remembered Coder-sans contest in which we were given a morse code for decoding ..
[Image: OilyCostlyEwe.gif]

Reply

RE: Morse Decoder #6
Wow that looks good , I think I am going to make one in C++ or in VB.NET too . Seeing this I remembered Coder-sans contest in which we were given a morse code for decoding ..
[Image: OilyCostlyEwe.gif]

Reply

RE: Morse Decoder #7
Really great job! I like that you are still making tools in Python. And you did a very great job at explaining that code also.

Reply

RE: Morse Decoder #8
Really great job! I like that you are still making tools in Python. And you did a very great job at explaining that code also.

Reply

RE: Morse Decoder #9
Nice. A job well done.
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: Morse Decoder #10
Nice. A job well done.
[Image: rytwG00.png]
Redcat Revolution!

Reply







Users browsing this thread: 1 Guest(s)