top of page

Forum Comments

ACSL Elementary - Graph Theory 2
In CS Fundamentals for ACSL
ACSL Elementary - Simplifying Boolean Expressions 1
In CS Fundamentals for ACSL
ACSL Elementary - Infix/Prefix/Postfix notations
In CS Fundamentals for ACSL
ACSL Elementary - Binary to Octal and Hexadecimal
In CS Fundamentals for ACSL
ygou88
Mar 08, 2022
CODE = {' ': '_', "'": '.----.', '(': '-.--.-', ')': '-.--.-', ',': '--..--', '-': '-....-', '.': '.-.-.-', '/': '-..-.', '0': '-----', '1': '.----', '2': '..---', '3': '...--', '4': '....-', '5': '.....', '6': '-....', '7': '--...', '8': '---..', '9': '----.', ':': '---...', ';': '-.-.-.', '?': '..--..', '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': '--..', '_': '..--.-'} def main(): print("This program translates words to morse code\n") words = input("Enter a word or phrase to be encoded: ") words = words.upper() codeDict = createDict() i = 0 try: while (i < len(words)): if (words[i] != " "): print(codeDict[words[i]], end = " ") else: print("/", end = " ") i += 1 except: print("\nInvalid characters found - refer to morse code alphabet") def createDict(): code = {'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': '-----'} return code main()
0
0
ACSL Elementary: Conversion between base 10 and base 2
In CS Fundamentals for ACSL

ygou88

More actions
bottom of page