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 or to determine the length of Lines and If lines and are length three, then line will be length four. If lines and are length four, then line 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.getHKtheDeadtxthad braved death.again. He watched sleepilydancing, the merrymaking
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
