Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(Using Python)******show all your codes and test it Your company realizes that t

ID: 3771843 • Letter: #

Question

(Using Python)******show all your codes and test it

Your company realizes that they probably need more than one synonym for each word, so they updated your thesaurus accordingly:

The dictionary contains two keys - "happy" and "sad". Each of these keys holds a list that contains synonyms of that key.

Write a program that asks the user for a phrase. Then compare the words in that phrase to the keys in the thesaurus. If the key can be found you should replace the original word with a random synonym for that word. Words that are changed in this way should be printed in UPPERCASE letters. Here's a sample running of your program:

Explanation / Answer

</code>

import random
thesaurus = {
"happy":["glad", "blissful", "ecstatic", "at ease"],
"sad" :["bleak", "blue", "depressed"]
}
print "Enter a phrase: ",
line = raw_input()
line = line.replace(",","") #removing comma(,) from phrase
words = line.split(' ') #spliting and making an array of words
ans = ""
for word in words:
if word in thesaurus:
x = random.randint(0, len(thesaurus[word]))
print thesaurus[word][x].upper(),
else:
print word,

</code>