Question: Use the python 1. [25 pts] Write a function avgWordLengthIn(Sentence), which takes a string, Sentence, of words separated by spaces, without any punctuation marks, including

Use the python 1. [25 pts] Write a function avgWordLengthIn(Sentence), which takesUse the python

1. [25 pts] Write a function avgWordLengthIn(Sentence), which takes a string, Sentence, of words separated by spaces, without any punctuation marks, including an ending period, and returns the average length of a word in Sentence. (Hint: use the split method for strings.] # Sample run: Sentence = 'I have not seen you in a long time William AWL = avgWordLengthIn (Sentence) print (AWL) # 3.3 2. [ 5 pts] Process the following five sentence string - use the function from Q1 to compute the average word length of each of the 5 sentences, put the average word length of each sentence into a list, then print out the list. It happened that a Dog had got a piece of meat and was carrying it home in his mouth to eat it in peace. Now on his way home he had to cross a plank lying across a running brook. As he crossed he looked down and saw his own shadow reflected in the water beneath. Thinking it was another dog with another piece of meat he made up his mind to have that also. So he made a snap at the shadow in the water but as he opened his mouth the piece of meat fell out dropped into the water and was never seen more." You have to process all the 5 sentences at once. Strip the final period from the above string. [ use strip(??)). Split the sentences into a list using period as a separator [ use .split('?') ). Finally, traverse the list one sentence at a time & use the function from Q1 to compute the average word length of each sentence, dot appending the average word length into a list accumulator. Finally, print out the list containing the average word length of the sentences

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!