1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
svlad2 [7]
3 years ago
14

Using Python

Computers and Technology
1 answer:
Mnenie [13.5K]3 years ago
8 0

Answer:

#section 1

import re

thesaurus = {

   "happy" : "glad",

   "sad" : "bleak",

   }

text =input('Enter text: ').lower()

#section 2

def synomReplace(thesaurus, text):

<em> # Create a regular expression  from the dictionary keys </em>

 regex = re.compile("(%s)" % "|".join(map(re.escape, thesaurus.keys())))

 

 # For each match, look-up corresponding value in dictionary

 return regex.sub(lambda x: thesaurus[x.string[x.start():x.end()]].upper(), text)

print(synomReplace(thesaurus, text))

Explanation:

#section 1

In this section, the regular expression module is imported to carry out special string operations. The thesaurus is initialized as a dictionary. The program then prompts the user to enter a text.

#section 2

In the section, we create a regular expression that will search for all the keys and another one that will substitute the keys with their value and also convert the values to uppercase using the .upper() method.

I have attached a picture for you to see the result of the code.

You might be interested in
A file with a com extension is most likely to be a(n) ___ file.
olasank [31]
I think that the answer is: A executable
4 0
3 years ago
Read 2 more answers
Everyone’s favorite speedy blue hedgehog recently returned to his 2D origins in a critically acclaimed side-scrolling game. What
forsale [732]
It was called sonic mania
3 0
3 years ago
Read 2 more answers
Which icon is greater in file size? (Show your working)
nadya68 [22]

Answer:

the 256 color icon would be greater in file size.

Explanation:

regardless of how many pixels are in the image, file A has 256 colors meaning the computer has to individually load each one of those colors. it'll probably use a lot of ink if you decide to print it, too.

5 0
3 years ago
What is the output of the following program? #include using namespace std; class TestClass { public: TestClass(int x) { cout &lt
Alik [6]

Answer:

An error will be occurred here. In C++ a function must be like

returntype function_name(){

}

but the functions in given class does not have returntype given. So there will be a syntax error.

If the returntype is defined then the code does not show any output since nothing is printed in the main function.

4 0
3 years ago
This organization created web standards to be followed in the creation and contentof a web page​
kumpel [21]

Answer:

The World Wide Web Consortium (W3C) is an international community where member organizations, a full-time staff, invited experts and the public work together to develop Web Standards. Led by Web inventor and Director Tim Berners-Lee and CEO Jeffrey Jaffe, W3C's mission is to lead the Web to its full potential.

<em />

<em>Hope you got it</em>

4 0
3 years ago
Other questions:
  • The first character of the VIN designates which of the following? 
    15·2 answers
  • The Glow effect adds a blinking border around a chart.<br> t or f
    15·1 answer
  • "Because Standard Error and Standard Ouput represent the results of a command and Standard Input represents the input required f
    6·1 answer
  • Which best describes a hybrid drive?
    11·1 answer
  • Which of the following should you consider when
    5·1 answer
  • Divide 111001 by 1101​
    7·1 answer
  • A mesh network topology allows all computers to be directly connected. True or False
    9·1 answer
  • What number is represented as a binary code of 101110
    5·2 answers
  • Edge is a video game featuring interactive extreme sports. The graphics used in the game are protected by
    8·1 answer
  • Tasha grew up helping her uncle work on cars in his auto repair shop and developed into an excellent auto technician. Because of
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!