subject

Using python

you have been hired by a small software company to create 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 a sample running of your program:

enter a phrase: happy birthday! exclaimed the sad, sad kitten
glad birthday exclaimed the bleak bleak kitten

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 04:31, manlyman31
Selling a product through an electronic medium is
Answers: 1
image
Computers and Technology, 23.06.2019 09:10, djs1671
(328 inc. 448 ind. 480 in25. john has a collection of toy cars. he has 2 red cars, 4 blue cars, 4 black cars, and 6 yellowcars. what is the ratio of red cars to yellow cars? a. 1: 2b. 1: 3c. 1: 626. the net of a right triangular prism is shown below.
Answers: 2
image
Computers and Technology, 23.06.2019 19:30, wilkinsonei4069
Anul 2017 tocmai s-a încheiat, suntem trişti deoarece era număr prim, însă avem şi o veste bună, anul 2018 este produs de două numere prime, 2 şi 1009. dorel, un adevărat colecţionar de numere prime, şi-a pus întrebarea: “câte numere dintr-un interval [a, b] se pot scrie ca produs de două numere prime? “.
Answers: 1
image
Computers and Technology, 24.06.2019 16:50, Ameilasmickle15
How many types of string types does python support?
Answers: 1
You know the right answer?
Using python

you have been hired by a small software company to create a "thesaurus" pro...

Questions in other subjects:

Konu
Mathematics, 01.02.2021 03:50
Konu
Mathematics, 01.02.2021 03:50
Konu
Chemistry, 01.02.2021 03:50
Konu
Mathematics, 01.02.2021 03:50