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 first priority when building or using vex robots
zepelin [54]
Hey I’m doing that too
8 0
3 years ago
Read 2 more answers
Determine which system you would recommend each of the customers use based on their provided user and system specs.
Ratling [72]

Answer:

Hope this helps pls mark brainiest

Explanation:

<h2> </h2><h2>So we know Student B is gonna get a computer, but its not stated if its A desktop or laptop. hmm,.. So ima do both for the desktop he would what a computer with "Ethernet Storage Fabrics: 25GbE, 50GbE" because If he going to do videos in todays standers it would be in 4k and 8k. he would also need at least 16 of ram if not 32gb. and since he has no cap budget I would personally go for the i9, but he can go for the i7, not much of a fan of the i5 for video productive, for storage he would need a lot for video editing or other stuff so I would go for the main boot (sys) a  and for the actually storage for the videos I would go for a  with good rpm. For  I would go for something with 8-10 or higher.</h2>

7 0
2 years ago
Credit card numbers follow a standard system. For example, Visa, MasterCard, and Discpver Card all have 16 digits, and the first
fgiga [73]

Answer:

try:

   cardNumber = str(input('Enter your card number her: \n'))

   if (len(cardNumber) > 16 or len(cardNumber < 16)):

       raise

except:

   print ('You have entered an invalid cardNumber.')

else:

   if cardNumber.startswith("2"):

       print('American Express Card')

   elif cardNumber.startswith("4"):

       print('Visa Card')    

   elif cardNumber.startswith("5"):

       print('Master Card')    

   else:

       print('Unknown Card')

Explanation:

In the try block section:

The first line prompt the user for input, which is converted to string and assigned to cardNumber variable. The next line test the length of the cardNumber entered, if it is less than 16 or greater than 16; an exception is raise.

In the except section:

An error message is displayed telling the user that he/she has entered an invalid card number.

In the else section:

This is where is program check for type of card using an if...elif...else statement block. If the cardNumber start with 2; an output of "American Express card" is displayed. If the cardNumber start with 4; an output of "Visa card" is displayed. If the cardNumber start with 5; an output of "Master card" is display else "Unknown card" is displayed to the user.

5 0
3 years ago
Logical design is tied to a specific hardware and software platform. a. True b. False
cluponka [151]

Answer:B false

Explanation:

3 0
3 years ago
It is usually simple to delete old posts and online conversations if they make you look bad.
denis23 [38]

Answer:

not usually..sorry :(

Explanation:

7 0
3 years ago
Other questions:
  • 2. Now write a program named filereader.py that reads and displays the data in friends.txt. This program should also determine a
    5·1 answer
  • Which location-sharing service offers items for users as a gaming component and also allows them to collectively link their chec
    9·2 answers
  • You are purchasing several PC systems that will be used as thin clients in a large organization. Which hardware selection criter
    9·1 answer
  • Among the second generation home console companies,which managed to come out on top
    10·1 answer
  • In terms of CPU scheduling metrics, __________ is the time at which the job completes minus the time at which the job arrived in
    10·1 answer
  • What is the second stage of information processing cycle​
    10·2 answers
  • Write a class called TextProcessor that implements the methods listed below. Your implementation may use the charAt() and length
    14·1 answer
  • Assignment 6: Animation
    7·1 answer
  • Why optical disk is slower than magnetic disk.?​
    9·2 answers
  • What does playstation network is currently undergoing maintenance?.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!