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
Semmy [17]
4 years ago
8

Write a program that takes nouns and forms their plurals on the basis of these rules:

Computers and Technology
1 answer:
soldi70 [24.7K]4 years ago
4 0

Answer:

def nounToplural(tex):

   import re

   

   text = tex.split()

   new = []

   for word in text:

       if re.findall(r"y\b", word):

           word = re.sub(r"y\b", 'ies' ,word)

           new.append(word)

       

       elif re.findall(r"ch\b", word):

           word = re.sub(r"ch\b", 'ches' ,word)

           new.append(word)

       elif re.findall(r"sh\b", word):

           word = re.sub(r"sh\b", 'shes' ,word)

           new.append(word)

       elif re.findall(r"s\b", word):

           word = re.sub(r"s\b", 'ses' ,word)

           new.append(word)

       else:

           word = word + 's'

           new.append(word)

   result = []

   for i in text:

       for j in new:

           if new.index(j) == text.index(i):

               result.append( (i,j) )

           

           

   print(result)

str = "chair dairy boss circuis fly dog church clue dish"

nounToplural(str)

Explanation:

We made use or Regular Expressions which is simply a special sequence of characters that helps you match or find other strings or sets of strings, by using a specialized syntax held in a pattern.

Firstly, define the function and import the regular expression module, split the text into a list and create an empty list to hold the plural list.

For every word in the list  we check with IF statements and regular expressions to find out what they end with.

 if re.findall(r"y\b", word):

           word = re.sub(r"y\b", 'ies' ,word)

           new.append(word)

The above IF block checks if a noun ends with 'y', if it does it replaces the 'y' with 'ies' and ads it to the new list.

If it does not, ot moves to the next IF/ELIF block.

In the ELIF blocks carry out a  a similar operation for "s", "ch", or "sh", in order to add "es".

Finally, 's' is added to all other cases using the ELSE block which traps any noun that did not fall under the IF or any of the ELIF blocks.

This last part of the code prints both list side by side and passes them to a new list result which is printed to the screen

<em>result = [] </em>

<em>    for i in text: </em>

<em>        for j in new: </em>

<em>            if new.index(j) == text.index(i): </em>

<em>                result.append( (i,j) ) </em>

<em>             </em>

<em>             </em>

<em>    print(result)</em>

I called the function and passed the string you provided in your question and attached the result of the code.

You might be interested in
What is the purpose of using specialized supply chain software?
weeeeeb [17]

Answer:

The purpose of supply chain management is

On the most basic level, the purpose of supply chain management is to make inventory readily available in customer facing positions to fulfill demand. ... Supply chain partners must work together to maximize resource productivity, develop standardized processes, eliminate duplicate efforts, and minimize inventory levels

Explanation:

4 0
3 years ago
In C Coding, print either "Fruit", "Drink", or "Unknown" (followed by a newline) depending on the value of userItem. Print "Unkn
shutvik [7]

The code below uses if-else structure to print the output depending on the value of the userItem.

If the specified condition in the if structure is true, the block in the structure gets executed.

Comments are used to explain the each line of the code.

//main.c

#include <stdio.h>

int main()

{  

   //defining the enum and userItem

   enum GroceryItem {GR_APPLES, GR_BANANAS, GR_JUICE, GR_WATER};

   enum GroceryItem userItem;

   //initializing the userItem

   userItem = GR_APPLES;

   

   //checking the userItem

   //If it is GR_APPLES or GR_BANANAS, print "Fruit"

   //If it is GR_JUICE or GR_WATER, print "Drink"

   //Otherwise, print "Unknown"

   if(userItem == GR_APPLES || userItem == GR_BANANAS){

       printf("%s\n", "Fruit");

   }

   else if(userItem == GR_JUICE || userItem == GR_WATER){

       printf("%s\n", "Drink");

   }

   else{

       printf("%s\n", "Unknown");

   }

   

   return 0;

}

You can see a similar question at:

brainly.com/question/17592042

6 0
3 years ago
Business process re-engineering
Lorico [155]

Answer:

d. asks you to rethink the way you are doing your work.

Explanation:

A business strategy generally sets the overall direction for a business and as it focuses on defining how a business would achieve its goals, objectives, and mission; as well as the funds and material resources required to implement or execute the business plan.

Business process re-engineering can be defined as a strategic technique which typically involves being innovative while discarding old business processes, procedures and ideas in order to achieve maximum level of success.

Hence, business process re-engineering asks you to rethink the way you are doing your work.

For example, if you use manual labor for the production of your goods but then decided to start using automated machines for the production and packaging of your products. .

8 0
3 years ago
Select all True statements! Question 1 options: a) Host A is sending Host B a large file over a TCP connection. Assume Host B ha
VikaD [51]

<u>Solution:</u>

a)   False. Piggyback is used only for efficiency. If there's no data packet to be piggybacked to, then B will just send the acknowledgement packet.

b)  False. It is the size of the receiver's buffer that's never changed. RcvWindow is the part of the receiver's buffer that's changing all the time depending on the processing capability at the receiver's side and the network traffic.

c)  The given statement is True.

 d) False. The sequence number of the subsequent segment depends on the number of 8-byte characters in the current segment.

e)  True. Every TCP segment has a current value of rwnd in the receive window.

f)  False. Next_RTT = alpha * last_estimated_RTT + (1-alpha)*newly_collected_RTT_sample. In this case even though the last sampleRTT which is the newly_collected_RTT_sample is 1sec, the next_RTT still depends on alpha and last_estimated_RTT. Therefore, the next_RTT is not necessarily greater than 1sec.

g) False. The acknowledgement number has nothing to do with the sequence number. The ack. number indicates the next sequence number A is expecting from B.

5 0
4 years ago
Explain how low atmospheric oxygen level affected alligator growth in terms of cellular respiration
geniusboy [140]

Answer: Hyperoxic alligators show significantly lower breathing rates than their siblings in normoxic and hypoxic groups. Conversely, each breath supports greater oxygen consumption in hyperoxic animals than in other groups. Statistical significance between groups was calculated by ANOVA with post hoc Tukey–Kramer

Explanation:

4 0
3 years ago
Other questions:
  • Which function is used to display a string value to the screen?
    8·1 answer
  • A. True <br><br> b. False: most modern computers can understand and execute pseudocode.
    7·1 answer
  • Sending an e-mail message to customers or potential customers of a legitimate website asking them to click a link that leads to
    10·1 answer
  • What does limited access to a document mean? A. It makes a document inaccessible without a password. B. It enables a person to m
    7·1 answer
  • I REALLY NEED HELP WITH THIS ASSIGNMENT. IT WOULD BE GREATLY APPRECIATED IF SOMEONE HELPED ME. I'M NOT GOOD AT COMPUTER SCIENCE
    6·2 answers
  • HELLLPPPPPP For each of the following discussion questions, write a response in complete sentences. Your response should be at l
    6·1 answer
  • What are three limitations of computer?​
    13·1 answer
  • Question 3 (8 marks): Write a program that takes a string from the user and splits it into a list using a space (" ") as the del
    13·1 answer
  • after landing, you are tying down the aircraft when a person approaches and asks: "faa. are you the pilot of this aircraft?" wha
    11·1 answer
  • Anyone here good with Alice? I need help ASAP
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!