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 #1(bold, underlined text is what the user types):
File? file1.txt
Words in alphabetic order:
and 2
away 1
cat 1
cow 1
diddle 2
dish 1
dog 1
fiddle 1
hey 1
jumped 1
laughed 1
little 1
moon 1
over 1
ran 1
see 1
spoon 1
sport 1
such 1
the 7
to 1
with 1
Words in descending frequency:
7 the
2 diddle
2 and
1 with
1 to
1 such
1 sport
1 spoon
1 see
1 ran
1 over
1 moon
1 little
1 laughed
1 jumped
1 hey
1 fiddle
1 dog
1 dish
1 cow
1 cat
1 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!