Question: Python/Jupitarlabs - Each question builds off the others. Question 1. Write a function called ReadTextFile that accepts a string path to the provided file as

Python/Jupitarlabs - Each question builds off the others.

Question 1. Write a function called ReadTextFile that accepts a string path to the provided file as an argument, opens the file, splits the file on spaces, and then returns a list of those strings.

Arguments: String - a path to the puppy.txt file

Return: A list of strings

Question 2. Write a function called CountWords that takes a list of strings from Question 1 as an argument and returns a dictionary. The dictionary's keys are the unique words found in the text and the values are the number of times they appear in the text.

Arguments: A list of strings

Return: A dictionary with string keys/integer values

Question 3. Write a function called CountsToFrequency that takes the dictionary of word counts from the Question 2 as an argument and returns a new dictionary with the same keys as the source and the frequency of each word as values. The frequency is equal to the word count divided by the total number of words in the dictionary.

Arguments: A dictionary with string keys/integer values

Return: A dictionary with string keys/float values

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!