Question: Write a function called random _ text ( source _ file, num _ words ) that takes in two parameters: source _ file is a

Write a function called random_text(source_file, num_words) that takes in two parameters:
source_file is a string representing the name of a file in the current directory, which well use as a basis for producing our text
num_words is an integer representing the number of words in our output text
You must read in the entire file as a string and call the follows function from Part C to get a dictionary with all the adjacent pairs of words in the file.
The function needs to return a string containing num_words words, separated by spaces. All of the words in the output string need to be from the source file. How each word is chosen depends on which option you choose below:

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!