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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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