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
You are called to assist in troubleshooting a network problem that has occurred soon after a significant IPv6 implementation. So
HACTEHA [7]

Answer:i dont kowe

Explanation:

5 0
3 years ago
Which part holds the "brains" of the computer?
Rus_ich [418]
The (CPU) holds the “brains” of the computer
7 0
3 years ago
Which of the following methods is a static method? The class in which the method is defined is given in parentheses following th
maw [93]

Answer:

C. sqrt(Math)

Explanation:

All but one of options A to E are is not a static method.

Only option C is a static method. The sqrt() is a static method of Math, that can always be used as Math.sqrt() is used;

The Math class defines all of its methods to be static. Invoking Math methods is done by using Math as a method rather than a variable of type Math; this means that sqrt(Math) doesn't rely on instance variables and don't need to be overridden, unlike others.

Lastly, sqrt(Math) is a static method because unlike other options, it is an utility method, and it is relevant to computations on primitive data types.

The purpose of the static method is in large part to offer a standard library of functions, and it doesn't need to be applied directly to an object.

4 0
3 years ago
3.<br>What is the meaning of *.VBP.<br>​
Kisachek [45]

Answer:

The meaning of VBP is Visual Basic Project

7 0
2 years ago
Read 2 more answers
Complete the program below that takes in one positive, odd, integer, n (at least 3), and prints a "diamond" shape of stars with
avanturin [10]

Answer:

n = int(input("Enter the n (positive odd integer): "))

for i in range(1, n+1, 2):

   print(i*"*")

for i in range(n-2, 0, -2):

   print(i*"*")

Explanation:

*The code is in Python.

Ask the user to enter the n

Create a for loop that iterates from 1 to n, incrementing by 2 in each iteration. Print the corresponding number of asterisks in each iteration

Create another for loop that iterates from n-2 to 1, decrementing by 2 in each iteration. Print the corresponding number of asterisks in each iteration

5 0
3 years ago
Other questions:
  • Write an original idiom that uses the word dog or dogs im in 4th
    5·2 answers
  • Remember for a moment a recent trip you have made to the grocery store to pick up a few items. What pieces of data did the Point
    15·1 answer
  • The _device provides a means of communication between a computer and outer world.​
    14·1 answer
  • Define additional characteristics such as font weight or style for an html tag
    5·1 answer
  • Write a function called count_occurrences that takes two strings. The second string should only be one character long. The funct
    13·1 answer
  • Write a Python program string_functions.py that defines several functions. Each function re-implements Python's built-in string
    9·1 answer
  • Which online article citation is correctly formatted according to MLA standards?
    15·2 answers
  • MULTIPLE CHOICE QUESTION
    14·2 answers
  • For any element in keysList with a value smaller than 40, print the corresponding value in itemsList, followed by a comma (no sp
    6·1 answer
  • When Alice turned on her laptop this morning, the screen displayed only colorful horizontal lines. Which of the following is mos
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!