Python Programming - Word Frequency count

Building a word frequency finding program The aim of this exercise is to write a program that prints the most frequent word in a statement.

* Instructions *

Finding the frequency of each word the statement.

  1. Define a variable called statement having any string, eg. "A quick brown fox jumped over the lazy dog".
  2. Initialize a dictionary called counts which will hold the frequency of the words.
  3. Using the split() function split the statement into words and store it in a list called words.
  4. Using a for loop iterate through each word in the list of words.
  5. In each iteration of the for loop use the get() method to see if the word exists in the dictionary if it does, increment its value by one. Else create a key with the word having a value of 0.

Printing the most frequent word.

  1. Since you have to find the most frequent word, define two variables,bigcount and bigword with a value of None, which will store the maximum frequency and most frequent word.
  2. Iterate through the dictionary counts and find the most frequent word.
  3. Print the most frequent word.

No hints are availble for this assesment

Answer is not availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...