Answered step by step
Verified Expert Solution
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
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 wcpy and must be run like so:
python wcpy 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,whenyourprogramisrunwiththisfilepython wcpy healthyeating.txt theoutputoftheprogramshouldbeintheballparkoflines: unique: words: chars: 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 wcpy healthyeating.txt will print:
lines: unique: words: chars:
Most frequent word:and times Less frequent word:People times
Again, your output may be slightly different than this depending on what you consider a word. eg you turn all words to lowercase or something like that
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started