Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4 . 1 Task Create a program that reads a filename from the command line and prints the number of unique words, total number of

4.1 Task
Create a program that reads a filename from the command line and prints the number of unique words, total number of words (not unique), characters (includ- ing spaces) and lines in that file. It must be called wc.py and must be run like so:
python wc.py filename
where filename is the actual name of the file to read.
As an example, download this sample file: heaalthyeating.txt. you can use this to test. I may run it with a different file.
Then,whenyourprogramisrunwiththisfile(python wc.py healthyeating.txt), theoutputoftheprogramshouldbeintheballparkoflines:42, unique:429, words:819, chars:4 The numbers may vary a bit, but not a lot.
Your program must print the most common and least common word. You must usedictionariesforthis.Usingthehealthyeating.txtfile,python wc.py healthyeating.txt will print:
lines:42, unique:429, words:819, chars:4878
Most frequent word:and (33 times), Less frequent word:People (1 times).
Again, your output may be slightly different than this depending on what you consider a word. (e.g. you turn all words to lowercase or something like that).

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

Step: 3

blur-text-image

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

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

How is a government budget deficit financed in an open economy?

Answered: 1 week ago