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
If you press the Tab key when you're in in the last cell of a table,
KengaRu [80]
The answer is B.

If you press the tab key when you're in the last cell of a table, you will add a new blank row
8 0
3 years ago
Read 2 more answers
Which of these might be an example of an advertiser's target group?
d1i1m1o1n [39]

Answer:

I would assume C. because it's the answer that makes the most sense.

Explanation:

D. would be the other choice however, just because they live in the same region doesn't mean they watch TV or have any access to media.

5 0
3 years ago
Read 2 more answers
6.- Escribe un ejemplo donde se utilice un sistema de información
lesya [120]

Answer:

<h3>Examples of information systems. Quality control systems. They are those in which there is customer feedback and the results are evaluated under statistics and final reports. The databases in a library. To organize and store file databases such as books, journals. journals, theses, etc.</h3>

Explanation:

8 0
2 years ago
What is the most widely used operating system for mobile devices?
Alekssandra [29.7K]
Android, many phone brands use the Android OS. Unlike Apple, which is the only technology company with IOS.
8 0
3 years ago
The readline method reads text until an end of line symbol is encountered, how is an end of line character represented
zhannawk [14.2K]

Answer:

\n

Explanation:

readline() method is used to read one line from a file. It returns that line from the file.    

This line from the file is returned as a string. This string contains a \n at the end which is called a new line character.

So the readline method reads text until an end of line symbol is encountered, and this end of line character is represented by \n.

For example if the file "abc.txt" contains the lines:

Welcome to abc file.

This file is for demonstrating how read line works.

Consider the following code:

f = open("abc.txt", "r")  #opens the file in read mode

print(f.readline()) # read one line from file and displays it

The output is:

Welcome to abc file.    

The readline() method reads one line and the print method displays that line.                        

3 0
3 years ago
Other questions:
  • Survey Q, Non-scoring: What role are you playing in your team?
    5·2 answers
  • You should hand write your references on your resume.
    15·2 answers
  • how to make assignment on power point plz cntct me and help me all about power point and my assignment is prime ministers of pak
    13·1 answer
  • Ciscon Telecom is a mobile operator in the European Union. The company provides personalized services to its customers, and its
    8·2 answers
  • Match the item to the type.
    11·1 answer
  • How do you respond to an email?
    6·1 answer
  • "Packet switches have multiple links attached to them. For each attached link the packet switch has a/an ____________, which sto
    7·1 answer
  • You work for a company that builds custom PCs for select clients. You are training a new employee to evaluate and select appropr
    13·1 answer
  • Explain Http and Ftp​
    12·1 answer
  • Please answer quick :(​
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!