Question

Using Python       1. Write a function to generate an index” for below passage. Insert this...

Using Python

      1. Write a function to generate an index” for below passage.

  • Insert this quote
  • passage =

"Writing programs or programming is a very creative and rewarding activity. You can write programs for many reasons ranging from making your living to solving a difficult data analysis problem to having fun to helping someone else solve a problem. This book assumes that everyone needs to know how to program and that once you know how to program, you will figure out what you want to do with your newfound skills. We are surrounded in our daily lives with computers ranging from laptops to cell phones. We can think of these computers as our personal assistants who can take care of many things on our behalf. The hardware in our current-day computers is essentially built to continuously ask us the question what would you like me to do next? A computer is fast and has vast amounts of memory and could be very helpful to us if we only knew the language to speak to explain to the computer what we would like it to do next. If we knew this language, we could tell the computer to do tasks on our behalf that were repetitive. Interestingly, the kinds of things a computer can do best are often the kinds of things that we humans find boring and mind-numbing."

Thank you, I would upvote!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

TOM UPCUP CU CEI PUOLICJI C CUCIIIIIICUL CHICJCCOMPUCCI OPET JULICI assistants who can take care of many things on our behalf

passage = "Writing programs or programming is a very creative and rewarding activity. You can write programs for many reasons ranging from making your living to solving a difficult data analysis problem to having fun to helping someone else solve a problem. This book assumes that everyone needs to know how to program and that once you know how to program, you will figure out what you want to do with your newfound skills. We are surrounded in our daily lives with computers ranging from laptops to cell phones. We can think of these computers as our personal assistants who can take care of many things on our behalf. The hardware in our current-day computers is essentially built to continuously ask us the question what would you like me to do next? A computer is fast and has vast amounts of memory and could be very helpful to us if we only knew the language to speak to explain to the computer what we would like it to do next. If we knew this language, we could tell the computer to do tasks on our behalf that were repetitive. Interestingly, the kinds of things a computer can do best are often the kinds of things that we humans find boring and mind-numbing."


def generateIndices(s):

    indices = dict()

    min = 0
    for word in s.split():
        if word not in indices:
            indices[word] = []
        index = s.index(word, min)
        min = index + len(word)
        indices[word].append(index)

    for (word, indexes) in indices.items():
        print(word, indexes)


generateIndices(passage)

**************************************************

Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.

Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.

Add a comment
Know the answer?
Add Answer to:
Using Python       1. Write a function to generate an index” for below passage. Insert this...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Read the article below. Realize this is just one study and I didn't see a reference...

    Read the article below. Realize this is just one study and I didn't see a reference to where it had been duplicated. There are all kinds of "studies" that can say anything you want, but jobs being replaced by automation is true to some extent although it's unlikely that this study has figured out the future accurately What kind of jobs in IT do you think could be automated? What non-IT jobs do you think could be automated? Does in...

  • The name of the subject is English, I hope you can solve it quickly Q1/ Read...

    The name of the subject is English, I hope you can solve it quickly Q1/ Read the following passage carefully: (20 Marks) The First Computer Programmer Ada Lovelace was the daughter of the poet Lord Byron. She was taught by Mary Somerville, a well-known researcher and scientific author, who introduced her to Charles Babbage in June 1833. Babbage was an English mathematician, who first had the idea for a programmable computer, In 1842 and 1843. Ada translated the work of...

  • write this program in python plz Many investment management companies are switching from manual stock trading...

    write this program in python plz Many investment management companies are switching from manual stock trading done by humans to automatic stock trading by computers. You've been tasked to write a simple automatic stock trader function that determines whether to buy, sell, or do nothing (hold) for a particular account. It should follow the old saying "Buy low, sell high!" This function takes 4 input parameters in this order: current_shares - current number of shares of this stock in the...

  • MANAGERIAL ACCOUNTING CASE STUDY.CASE ASSIGNMENT #1: Cortland Manufacturing, Inc.

    MANAGERIAL ACCOUNTING CASE STUDY.CASE ASSIGNMENT #1: Cortland Manufacturing, Inc.We constantly seem to be pricing ourselves out of some markets and not charging enough in others. Our pricing policy is pretty simple: we mark up our full manufacturing cost by 50%. That means a computer that costs us $2,000 to manufacture will sell for $3,000. Until now I thought this was a workable approach, but now I’m not so sure.Steve Works, CEO, Cortland Manufacturing, Inc. (CMI)Steve’s Controller, Sally Nomer, had just...

  • Application Case Salary Inequities at AstraZeneca More than 50 years after passage of the Equal Pay...

    Application Case Salary Inequities at AstraZeneca More than 50 years after passage of the Equal Pay Act, women in America still earn about 80 cents for every dollar earned by a man. That adds up to a loss for the average female worker of about $380,000 over a lifetime. Recently, the U.S. Department of Labor's Office of Federal Contract Compliance Programs (OFCCP) entered into an agreement with AstraZeneca, a large international pharmaceuticals firm, for the company to pay some of...

  • This problem demonstrates the use of import module. The Python programming language has many strengths, but...

    This problem demonstrates the use of import module. The Python programming language has many strengths, but one of its best is the availability to use many existing modules for various tasks, and you do not need to be an experienced computer programmer to start using these modules. We have given you some incomplete code; note that the very first line of that code contains an import statement as follows: import math This statement enables your program to use a math...

  • 1.2 Recruitment is one of the crucial functions of HRM. Based on the information provided below,...

    1.2 Recruitment is one of the crucial functions of HRM. Based on the information provided below, how would you describe THE COMPANY’s approach to recruitment, before and after the implementation of the Brand Ambassador Program? How did the use of social media lead to the revision of the whole approach regarding recruitment? How ‘THE COMPANY’ Developed a Brand Ambassador Program At ‘THE COMPANY’ we usually categorize Employment Brand at ‘THE COMPANY’ into four big ‘buckets’: candidate experience, brand ambassador programs,...

  • 1.Select the correct answer (treat this passage as an argument): Households that have guns are significantly...

    1.Select the correct answer (treat this passage as an argument): Households that have guns are significantly less likely to be victims of crime. Therefore, people should keep guns in their homes. Question 1 options: Unstated premise: The presence of guns causes a decrease in crime Unstated conclusion: People should keep guns in their homes Unstated premise: People should do things that make them less likely to be victims of crime No unstated elements None of the above. 2. Select the...

  • Harry and Joe's Repair Service Harry and Joe were friends in high school. They were both...

    Harry and Joe's Repair Service Harry and Joe were friends in high school. They were both interested in cars and were very skilled at repairing them. During the summer, they created summer jobs by taking care of neighbors' and friends' cars. They called their company Shade Tree Mechanics Co. They would pick up the car, bring it to Joe's backyard under a large shade tree, wash and wax it, do a tune- up, or perform other minor repairs as needed....

  • Python Project

    AssignmentBitmap files map three 8-bit (1-byte) color channels per pixel. A pixel is a light-emitting "dot" on your screen. Whenever you buy a new monitor, you will see the pixel configuration by its width and height, such as 1920 x 1080 (1080p) or 3840x2160 (4K). This tells us that we have 1080 rows (height), and each row has 1920 (width) pixels.The bitmap file format is fairly straight forward where we tell the file what our width and height are. When...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT