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
What is the difference between concrete language and abstract language? give an example of each.
saul85 [17]

The difference between abstract language and abstract language is that abstract language is known through the intellect and concrete language is known through the senses.

<h3>What are abstract and concrete languages?</h3>

The abstract language uses the words like kind, truth, grace, etc. It is a form of language that indicates the intellectual, but concrete language can be known by the senses.

Thus, the distinction between concrete and abstract language is that concrete language is understood via the senses, whereas abstract language is understood through the mind.

To learn more about abstract and concrete languages, refer to the link:

brainly.com/question/16550006

#SPJ4

7 0
1 year ago
What is an electronic medical record
Airida [17]
EGC . medical research science
3 0
3 years ago
Differentiate between programming and coding
r-ruslan [8.4K]
Coding means creating codes from one language to another. Programming means to program a machine to perform using a set of instructions.
7 0
3 years ago
Which of the following is not an operating system service?
skad [1K]

Answer:

c. graphical user interface

Explanation:

An operating system may be defined as the system software which manages the various computer hardware, resources, software and also provides other computer services. It communicates the user with the computer and the computer runs according to the instruction provided by the operating system. It is commonly known as the OS.  

Operating system does not provide any graphical user interface. It consists of necessary components of the software to facilitate the usage or running of the computer.

5 0
3 years ago
Find the error in the following code fragment. int a: System.out.print(a):​
trapecia [35]

Answer:

If your using java, then its supposed to be "System.out.print("a")"    

Explanation:

its supposed to have quotations

7 0
3 years ago
Other questions:
  • The process of making raw materials into a finished product is known as
    14·2 answers
  • Write a program that checks for car mileage. if the mileage is greater than 100000, display "clunker!". if not, display "buy it!
    7·1 answer
  • When we insert a new node into a red-black tree, we set the color of the newly inserted node n to red. observe that if we had ch
    15·1 answer
  • If the motherboard is not getting power, it will not start the boot. ... A four-year old laptop will not boot and presents error
    13·1 answer
  • In a system using the relocatable dynamic partitions scheme, given the following situation (and using decimal form): Job Q is lo
    5·1 answer
  • An inventory management system that goes beyond just managing inventory to act as a complete distribution system (including inve
    10·1 answer
  • Matthew is running a study on the effects of room temperature on performance on an algebra test. One group takes the test in a r
    5·1 answer
  • Imagine that a crime has been committed and being a police officer you have to investigate the case. Solving a crime can be a ve
    12·1 answer
  • What is the purpose of flight simulator programs, and what are some of the benefits of using them?
    5·2 answers
  • A good machine should have the mechanical advantage of......?​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!