Create a function dictify that takes

Assignment Help Basic Computer Science
Reference no: EM131961516

Python 3

Do not import any package please

Q8: War and Peace
Your challenge for this problem is to create a function dictify that takes in 1 argument: book_name.
book_name: the string that is the name of the file to open
return: a dictionary containing the count of each length of word in sorted order. Eg. How many words total of length 1, 2, 3...?

Your output should look like (we cut out most of the dictionary): {6: 48342, 15: 254, 23: 2}

Hints:
Read in files using infile = open(filename), make sure that you are in the same directory.
Read each line by looping through with a simple for loop
Split the lines using line.split(" "), to get a list of the words
Since the book is long and complex, you might get zero length words (some tabs and spaces). Make sure to filter those out of your dictionary!
Your output dictionary should have its keys in sorted order, so {1: xxxx, 2: xxxxx, 3: xxxxx ...}

War and Peace. Part 2
Your challenge for this problem is to create a function process_book that takes in 2 arguments: book_name and mode.
book_name: the string that is the name of the file to open
mode: a string that is either "average" or "median"return: the "average" word length in the book or the "median" word length in the file, depending on the second argument.
Hint: We got a median word length of 4 for War and Peace.

Reference no: EM131961516

Questions Cloud

How might a blind person perform on an imagery task : How might a blind person perform on an imagery task? 200 words, references. The response must be typed.
How dissertation topic contribute to positive social change : Describe how your dissertation topic and potential findings might contribute to positive social change. The response must be typed, single spaced.
Make sure the transaction completes as desired : What should the recovery procedure perform to make sure the transaction completes as desired?
Examine circumstances surrounding a catastrophe : In this Discussion, you examine circumstances surrounding a catastrophe in which you must communicate important information to many people as quickly.
Create a function dictify that takes : Your challenge for this problem is to create a function dictify that takes in 1 argument: book_name.
Addition to numbers or strings : With Python, could a dictionary entry have a key value that is a list or a tuple, in addition to numbers or strings?
Write a paper on the pharisees and luke : Write a 1000 word paper on the Pharisees and Luke 7:36-50. Students will read am article on the Pharisees. They will then write a paper composes of two parts.
Discuss the importance of scripting : Discuss the importance of scripting regarding its flexibility both as a tool, and as a resource? Discuss a few different ways scripting can be useful
The main differences between cashflow and revenue : Determine whether or not you prefer your company to be cash flow positive or achieve a break-even point. Provide support for your response.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Describe risks to network security

Describe risks to network security and how they affect an organization, including the use of supporting examples

  What is the firm accounts receivable balance

What is the firm's accounts receivable balance? (Round intermediate calculations to 1 decimal places, e.g. 15.1. and final answer to nearest whole dollar, e.g.

  How does the performance change in the absence

how does the performance change in the absence of barrier synchronization?

  Prepare a data dictionary entry and process description

Prepare a list of data stores and data flows needed for your Team Process Assignment. Under each data store, list the data elements required - Prepare a data dictionary entry and process description for your Team Process Assignment.

  What is the problem with implementation inheritance

Where can I find more details on how Java implements references and does garbage collection? What exactly does it mean to import a name? What is the problem with implementation inheritance?

  Advancements in computer design

Consider the following: Advancements in computer design are outpacing the life of the computer and its components. Within a matter of a few years, a computer is obsolete and ready to be replaced, leaving its owner with questions on how to properly..

  Executive summary and report

Read the Cyber Risk Report 2015 - Executive Summary and Report (Hewlett Packard, 2015), and the article Surveillance programs may cost US tech over $35 billion and its competitive edge (Taylor, 2015).

  Organization information systems

Even with the best security system, an organization's information systems are never fully safe from outside attacks or malicious activities from insiders. As a result, an organization must be prepared to take curative measures when an incident occ..

  Intelligence and business intelligence systems

Define business intelligence and Business Intelligence systems.

  Practice management software

Name at least three functions that are carried out through the use of Practice Management software (be specific in your answer).

  Explain why this relation is not normalized

Assume that ProjectNumber determines ProjectName and explain why this relation is not normalized?

  Name at least two such technologies

Several technologies have been practically given away by the United States to the world. Name at least two such technologies. Do you think that this was "charity" or that the United States reaps some benefits from having made the technologies wide..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd