Reference no: EM132323046
1. You have been hired by a small software company to make a "thesaurus" program that replaces words with their synonyms. The company has set you up with a sample thesaurus stored in a Python dictionary object. Here's the code that represents the thesaurus:
# define our simple thesaurus
thesaurus = {
"happy": "glad",
"sad" : "bleak"
}
The dictionary contains two keys - "happy" and "sad". Each of these keys holds a single synonym for 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. Make sure to remove all punctuation from your initial phrase so that you can find all possible matches.
Here's the sample run of your program:
Enter a phrase: Happy Birthday! exclaimed the sad, sad kitten
GLAD birthday exclaimed the BLEAK BLEAK kitten
Comment your source code and describe your code to someone who may be viewing it for the first time.