Question: Write a program to calculate the frequency of each word Prompt the user for a filename Make a dictionary of the words in the file
Write a program to calculate the frequency of each word
Prompt the user for a filename
Make a dictionary of the words in the file
The keys are the words
The values are the counts of how many times the word appears in the file
When reading the file, convert everything to lowercase so the and The count as the same word
Note that the test files will only contain words and whitespace. No punctuation
Print the words in alphabetical order
Print the words again in descending order of frequency
Sample Run #bold underlined text is what the user types:
File? filetxt
Words in alphabetic order:
and
away
cat
cow
diddle
dish
dog
fiddle
hey
jumped
laughed
little
moon
over
ran
see
spoon
sport
such
the
to
with
Words in descending frequency:
the
diddle
and
with
to
such
sport
spoon
see
ran
over
moon
little
laughed
jumped
hey
fiddle
dog
dish
cow
cat
away
Note: This problem is part of a python coding class and covers dictionaries. This is an introductory level class, so please no classes please. There is a sample output of what the code is supposed to output whrn interacted with.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
