Question on Morse Code
CODE_LIST = [[' ', '/'], ['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', '----.'], ['?', '..--..'], ['!', '-.-.--'], ['\'', '.----.'], ['"', '.-..-.'], [',', '--..--']]
Programming #1 Morse Code Filename: morse_partl . py . If you create another file to define other functions in, that's fine, just make sure you submit it! Morse code is a single-character encoding (that is still!) used in some sectors of telecommunications. It encodes text characters as standardized sequences of two different signal durations called dots and dashes. Morse code is named for Samuel F. B. Morse, who used to own a house in my NY hometown (Poughkeepsie, NY). You can learn more about Morse code here: https://en.wikipedia.org/wiki/Morse_code So... you may not be an aviator or a Ham Radio operator, but we're going to design and implement a solution to convert our natural language to Morse code (aka "Morse"). Given the following Python list of lists (where each list element is a list of two strings - the first string is the alpha character and the second string is the Morse representation). Copy this list to use in your program as the "lookup table" between alpha and Morse characters. CODE_LIST = [[' ', '/ ' ], ['A' , ' .- ' ], [' B' , ' -. .. ' ], ['C' , ' -. -. '], ['D' , ' -.. '], ['E' , '. '], [ 'F ' , ' . . -. ' ], ['G' , ' --. ' ], ['H' , '. .. . ' ], ['I' , ' . . ' ], ['j' , ' ."--' ], [ 'K' , ' - .- '], ['L' , ' .-.. '], ['M' , ' -- '], ['N' , ' -. '], ['0' , '---'], [ 'P', . -- . '], ['Q', ' --.- '], ['R' , ' . -. '], ['s' , '. . . ' ], ['T', ' -'], [ 'U' , ' . .- '], ['V', '. ..-'], ['W', '.--'], ['x', ' -..-'], ['Y', '-.--'], [ 'Z' , ' - -. . '], ['0', ' -- - - - '], ['1' , ' . ---- '], ['2' , ' . . "-- ' ], ['3' , '. . ."-'], [ '4' , ' . . . . - '], ['5' , ' . . ... '], ['6' , ' -.... ' ], ['7' , ' --...' ], [ ' - -. . '], ['9', ' - - --. '], ['?' , ' . . --. . '], ['!' , ' -. -. --'], [ " - ---. '], [.", ' .-. .-.'], [',', ' --.."-']] For program 1, you are to build a solution to convert user input (alphanumeric format) to Morse. After printing a welcome message, the user should be able to enter an alphanumeric message (in any language that supports the Latin/Modern English alphabet characters) and receive back the Morse code version of what they typed in. This input/translate/print message cycle should continue until the user enters the special "quit" sequence :q:Sample runs of the program are below: RESTART: /Users/keithbagley/Dropbox/NORTHEASTERN UNIVERSITY/C$5001/Fall 2019/Homework actice/morse_part1. py Welcome to the Morse Code Application. We love dots n dashes! Enter your alphanumeric messages & I'll convert them to Morse Enter :q: to stop and return to the main menu Your message: hello world! Original message: hello world! Translated message: . . . . Your message: I love CS5001! Original message: I love CS5001! Translated message: . . / .-.. Your message: How about you? Original message: How about you? Translated message: .... .-- / -. . --- . - . .--.. Your message: Your message: Bonjour mon ami! Original message: Bonjour mon ami ! Translated message: -. .. --- -. . --- --- . . -- . . Your message: Ca va? Original message: Ca va? Translated message: -.-. . .--. . Your message: Ca va bien! Original message: Ca va bien! Translated message: -.-. .- / .. .- - / -. . . . Your message: :q: -- Thanks for using our app -- --- --- - . . -. .. -.-- . Requirements: Allow the user to enter alphanumeric phrases until they explicitly quit : q: Print both the original alphanumeric message and the Morse translation Morse output: Individual Morse code characters should be separated by one space and words separated by a slash / For example, So on would be printed as: dotdotdot dashdashdash / dashdashdash dashdot. Without the slash the output would be SOON Exit gracefully with a friendly user message If the user inputs a message that cannot be processed, print a message indicating that Your message: crazy$^ message Your message had unknown characters. Could not convert it. Your message: Helpful hints: . Review the List handout. Remember, lists and strings are sequences that we can iterate over, or access via indexes. Our CODE_LIST is a list that contains multiple lists that contain strings. AMAZING points: Use CONSTANTS as we discussed in class so there are no numeric literals in your code