psf/black code formatting (#1277)

This commit is contained in:
William Zhang
2019-10-05 01:14:13 -04:00
committed by Christian Clauss
parent 07f04a2e55
commit 9eac17a408
291 changed files with 6014 additions and 4571 deletions

View File

@@ -2,68 +2,93 @@
# Dictionary representing the morse code chart
MORSE_CODE_DICT = { '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':'-----', ', ':'--..--', '.':'.-.-.-',
'?':'..--..', '/':'-..-.', '-':'-....-',
'(':'-.--.', ')':'-.--.-'}
MORSE_CODE_DICT = {
"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": "-----",
", ": "--..--",
".": ".-.-.-",
"?": "..--..",
"/": "-..-.",
"-": "-....-",
"(": "-.--.",
")": "-.--.-",
}
def encrypt(message):
cipher = ''
cipher = ""
for letter in message:
if letter != ' ':
if letter != " ":
cipher += MORSE_CODE_DICT[letter] + ' '
cipher += MORSE_CODE_DICT[letter] + " "
else:
cipher += ' '
cipher += " "
return cipher
def decrypt(message):
message += ' '
message += " "
decipher = ''
citext = ''
decipher = ""
citext = ""
for letter in message:
if (letter != ' '):
if letter != " ":
i = 0
citext += letter
else:
i += 1
if i == 2:
if i == 2 :
decipher += ' '
decipher += " "
else:
decipher += list(MORSE_CODE_DICT.keys())[list(MORSE_CODE_DICT
.values()).index(citext)]
citext = ''
decipher += list(MORSE_CODE_DICT.keys())[
list(MORSE_CODE_DICT.values()).index(citext)
]
citext = ""
return decipher
@@ -78,5 +103,5 @@ def main():
print(result)
if __name__ == '__main__':
if __name__ == "__main__":
main()