Question: PYTHON ONLY! Please follow directions Implement the function count_ word_ frequencies() in word_ frequencies .py that takes a list. of words as argument and returns

PYTHON ONLY! Please follow directions Implement the function count_ word_ frequencies() inPYTHON ONLY! Please follow directions

Implement the function count_ word_ frequencies() in word_ frequencies .py that takes a list. of words as argument and returns a dictionary whose keys are the words from the list and values are the corresponding frequencies. Also implement the function write-word _frequencies () that takes a dictionary as argument and writes (in reverse order of values) the key-value pairs of the dictionary to standard output, one per line, and with a ' rightarrow ' between a key and the corresponding value. $ python word-frequencies_ py it was the best of times it was the worst of times of rightarrow 2 it rightarrow 2 times rightarrow 2 the rightarrow 2 Was rightarrow 2 worst rightarrow 1 best rightarrow 1 import operator import stdio import sys # Returns a list containing the keys of the dictionary st in reverse order #of the values of the dictionary def keys (st): a= sorted (st. items (), key= operator. itemgetter (1), reverse= True) return [v[0] for v in a] # Returns a dictionary whose keys are the words from the given list of words # and values are the corresponding frequencies. def count_ word_ frequencies (words): # Writes (in reverse order of values) the key-value pairs of the dictionary #st to standard output, one per line, and with a ' rightarrow 'between a key and # the corresponding value def write _word_ frequencies (st): # Test client [DO NOT EDIT] .Reads words from standard input and writes # the words along with their frequencies, in reverse order of frequencies. Def_ main () words = stdio .read All Strings () write_ word_ frequencies (Count_ word_ frequencies(words)) if_ name_== ' _ main_': _main()

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 Databases Questions!