Question: Implement a function getText ( ) that takes fileName as a parameter. You may assume that the file is not empty. getText ( ) will

Implement a function getText() that takes fileName as a parameter. You may assume that the file is not empty. getText () will read a file to a String variable and then convert it to a list of strings. Each item in the list will be a word from the file. getText() will return a list of all the words. NOTE: do not worry about punctuation. You will need to remove any "In" characters from the text before splitting it into a list. Create a text file called sample.txt. Save several lines of text in this file. The information below shows how you would call the function getText () and what it would display:
Implement a function randomPhrase() that takes a filename and an integer, length. The function will randomly generates a phrase of consecutive words (punctuation intact) determined by length. Your function may use the gettext() function to obtain the list of strings. Your function will return a string of the length sent as a parameter.Implement a function getHK () which takes a filename as a parameter. This function will generate a random integer of 3 or 4 to determine the length of Lines 1 and 3. If lines 1 and 3 are length three, then line 2 will be length four. If lines 1 and 3 are length four, then line 2 will be length three. I suggest you use a text from the news or from an open source book. I used the short story the Dead by James Joyce.>getHK("theDead.txt")had braved death.again. He watched sleepilydancing, the merry-making
 Implement a function getText() that takes fileName as a parameter. You

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!