Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Homework 7 Write a program that analyzes Charles Dickens's David Copperfield. Your program should scan the file copperfield.txt and provide per-chapter statistics for the

Python image text in transcribed
Homework 7 Write a program that analyzes Charles Dickens's David Copperfield. Your program should scan the file copperfield.txt and provide per-chapter statistics for the total number of commas, total number of words and average word length. In addition to these statisties, your program should report the longest and shortest word in each chapter. You should aso create a list of all words used in the chapter. Sort the list alphabetically and report the first 10 words in the list. Extra Credit in your list of words, check to see if the word is in the list before adding it. If it is in the list, add it. If is not in the list, do not add it Hint When checking for the longest and shortest word, you will need to compare each new word you encounter to the current longest/shortest word and update the current longest/shortest accordingly. For the ist of words, the list should contain individual words and not lines of words or lists of words Output Statistics for chapter 1 ( AM BORN) Total conmasi 456 Total words: 4653 Avezage word length: 4.4156458195011395 Shortest word: Longest wordi Really-really-as ,After All, A, And, Anyhow, Last 10 woeds: you, you1, yoyou. you.' you?", young, younger, your, yourselt, youthful Statist i e, tor chapter 2OBSERVE, Total connas: 574 Total vorda: 6246 Average word length: 4.23807236631444 Longest words oomplexion--posound Pizst 10 words: "Bewitching, Pretty, good, "precty"yes". (oE, of (the, (when, (which 1ast 10 wordai you, you'", you'd, you youth, youthful you, you?, you?", young, your, Statiat Lca tor chapter 63 A VISTOR) Total ccrmaa: 341 Total worda: 3210 Average word length: 4.210903424791277 tongest vord: honestest-helping Laet 10 words i yeth.. you. you!, you'd you.11, yo yos?.. rung, younger

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The New Profit Frontier

Authors: Ed Burnett

1st Edition

0964535629, 978-0964535626

More Books

Students also viewed these Databases questions

Question

Describe how to measure the quality of work life.

Answered: 1 week ago

Question

What attracts you about this role?

Answered: 1 week ago

Question

How many states in India?

Answered: 1 week ago