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 removePunc 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 and the next multiple choice question. Each 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: newW-neww + ch return neww det wordt ist (line): words - 1 ist - line.split() for fragment #1: fragment #2) words.append() return words words with punctuation 12 Vog 31 = "Words, with, punctuation!?" print (wordList (51)) s2 = "This is a sentence, with a , 12, and punctuation.?" print (wordlist (32)) Output from main when wordList is correctly completed and executed. L'Words', 'with', 'punctuation'] I'This', 'is', 'a', 'sentence', 'with', 'a','','12', 'and', 'punctuation'] Which of the following code fragments would complete fragment #1? List of code fragments 1. words = W 2. w = removePunc(st) 3. W = removePunc(line) 4. W= removePunc(w) 5. W removePunc(w) + W 8. words in line 7. w in Ist 8 w in words 9. w in line 10 w in PUNC OA 3.8 OCO 0.7 E. 10

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

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions

Question

LO1 Understand risk management and identify its components.

Answered: 1 week ago