English to Morse and Morse to Binary converter.
More...
English to Morse and Morse to Binary converter.
This program houses a handful of definitions that help with conversions. The first definition converts an English statement into Morse Code. The second definition converts Morse code back to English. The third defintion converts morse code to binary units of morse code. The last and fourth definition is a validity checker to make sure all characters in an english statement are convertible to Morse Code before trying to convert to Morse or Binary. I personally borrowed the first two definitions from: https://www.geeksforgeeks.org/morse-code-translator-python/ LinkedIn for creator: https://www.linkedin.com/in/palash25/ I created the next two equations based off the found source code.
simon_says_game.py https://bitbucket.org/ColeSheedy/me-305-work-repository/src/master/LabWork/Lab3/simon_says_game.py
simon_says_game_class.py https://bitbucket.org/ColeSheedy/me-305-work-repository/src/master/LabWork/Lab3/simon_says_game_class.py
morse_code.py https://bitbucket.org/ColeSheedy/me-305-work-repository/src/master/LabWork/Lab3/morse_code.py
Youtube video of working game: https://www.youtube.com/watch?v=zqHnPY1ycLc
- Author
- Cole Sheedy
- Date
- 2/18/2021
- Copyright
- License info here.
◆ englishToMorse()
def morse_code.englishToMorse |
( |
|
message | ) |
|
Converts a string English statment to Morse Code dots and dashes.
- Parameters
-
message | String message which must only contain characters in above MORSE_CODE_DICT. |
◆ morseToBinary()
def morse_code.morseToBinary |
( |
|
message | ) |
|
Converts a Morse Code statement of dots and dashes to Binary units according to International Morse Code rule.
- Parameters
-
message | String message which must only contain dashes, dots, and spaces according to International Morse Code rule. |
◆ morseToEnglish()
def morse_code.morseToEnglish |
( |
|
message | ) |
|
Converts a Morse Code statement of dots and dashes to English.
- Parameters
-
message | String message which must only contain dashes, dots, and spaces according to International Morse Code rule. |
◆ validityCheck()
def morse_code.validityCheck |
( |
|
phrase | ) |
|
Checks if a statement only contains valid characters in the MORSE_CODE_DICT.
- Parameters
-
phrase | String message which hopefully only contains characters in the MORSE_CODE_DICT |
- Returns
- 1 if all characters are valid, 0 if otherwise.
◆ MORSE_CODE_DICT
dictionary morse_code.MORSE_CODE_DICT |
Initial value: 1 = {
'A':
'.-',
'B':
'-...',
2 'C':
'-.-.',
'D':
'-..',
'E':
'.',
3 'F':
'..-.',
'G':
'--.',
'H':
'....',
4 'I':
'..',
'J':
'.---',
'K':
'-.-',
5 'L':
'.-..',
'M':
'--',
'N':
'-.',
6 'O':
'---',
'P':
'.--.',
'Q':
'--.-',
7 'R':
'.-.',
'S':
'...',
'T':
'-',
8 'U':
'..-',
'V':
'...-',
'W':
'.--',
9 'X':
'-..-',
'Y':
'-.--',
'Z':
'--..',
11 'c':
'-.-.',
'd':
'-..',
'e':
'.',
12 'f':
'..-.',
'g':
'--.',
'h':
'....',
13 'i':
'..',
'j':
'.---',
'k':
'-.-',
14 'l':
'.-..',
'm':
'--',
'n':
'-.',
15 'o':
'---',
'p':
'.--.',
'q':
'--.-',
16 'r':
'.-.',
's':
'...',
't':
'-',
17 'u':
'..-',
'v':
'...-',
'w':
'.--',
18 'x':
'-..-',
'y':
'-.--',
'z':
'--..',
19 '1':
'.----',
'2':
'..---',
'3':
'...--',
20 '4':
'....-',
'5':
'.....',
'6':
'-....',
21 '7':
'--...',
'8':
'---..',
'9':
'----.',
22 '0':
'-----',
', ':
'--..--',
'.':
'.-.-.-',
23 '?':
'..--..',
'/':
'-..-.',
'-':
'-....-',
24 '(':
'-.--.',
')':
'-.--.-'}
Morse code character dictionary to reference.