Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The function wordList takes a line of text (a sentence) and splits it into words and returns a list of individual words in the sentence

image text in transcribed
image text in transcribed
The function wordList takes a line of text (a sentence) and splits it into words and returns a list of individual words in the sentence where each word has no punctuation. This function should make use of the function removePunc presented in the previous questions. Recall that the function remove Punc when implemented correctly removes all punctuation from a string. The code for the function wordList is provided below with some code fragments missing. Examples of the execution of the code when correctly completed are also provided. A numbered list of code fragments (pieces of Python statements or Python lines of code) are provided. You are to complete the function by selecting the correct answer to the multiple choice question below. The question will give you a choice of fragments from which to choose. You are to choose the correct code fragment to complete the indicated missing fragment (e.g. "fragment #1"). PUNC - ".,:'\"?!" def remove Punc (w): new- for ch in w: if ch not in PUNC: new-neww+ch return new def wordlist (line): words 1st - line.split() for fragment #1: fragment #2) words.append (w) return words ***** Main Program 31 - Words, with, punctuation!?" sl = "Words, with, punctuation!?" print (wordList (sl)) 32 "This is a sentence, with a , 12, and punctuation.?" print (wordlist (s2)) Output from main when wordList is correctly completed and executed. I'Words', 'with', 'punctuation'] 'This', 'is', 'a', 'sentence', 'with', 'a','','12', 'and', 'punctuation'] Which of the following code fragments would complete fragment #2? List of code fragments 1. words w 2. W = removePuncilst) 3. W = removePunc(line) 4. W = removePunc(w) 5. W = removePunc(w) + W 6. words in line 7. w in Ist 8. w in words 9. w in line 10. w in PUNC O A3 OB2 O 0.1 ES

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

7:067 Answered: 1 week ago

Answered: 1 week ago