-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconversor03.py
71 lines (49 loc) · 1.54 KB
/
conversor03.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def displayMenu():
print("trdtr de exprss")
print("=" * 13)
print("Menu: ")
print(" c = converter um frase")
print(" p = imprimir dicionario")
print(" a = adicionar uma palavra")
print(" d = remover uma palavra")
print(" q = sair")
def convertSentence():
sentence = input("Insira uma frase para traduzir:").lower()
translatedSentence = ""
listOfWords = sentence.split()
for word in listOfWords:
if word in textSpeakDictionary:
translatedSentence += textSpeakDictionary[word] + ' '
else:
translatedSentence += word + " "
print("==>")
print(translatedSentence)
def addDictionaryItem():
txtToAdd = input("Insira a expressão a ser adicionada ao dicionario: ")
meaning = input("O que ela significa?: ")
textSpeakDictionary[txtToAdd] = meaning
def deleteDictionaryItem():
txtToDelete = input("Insira a expressão a ser removida ao dicionario: ")
del textSpeakDictionary[txtToDelete]
textSpeakDictionary = {
"rs" : "risos" ,
"tmb" : "tambem" ,
"vc" : "você" ,
"pq" : "porque"
}
runnig = True
displayMenu()
while running == True:
menuChoice = input(">_").lower()
if menuChoice == 'c':
convertSentence()
elif menuChoice == 'p':
print(textSpeakDictionary)
elif menuChoice == 'a':
addDictionaryItem()
elif menuChoice == 'd':
deleteDictionaryItem()
elif menuChoice == 'q':
running = False
else:
print("Escolha invalida!")