Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python question def countWords(document): #This function counts the occurrence of every word in the string document #In today's version, you can assume document has no

Python question

def countWords(document): #This function counts the occurrence of every word in the string "document" #In today's version, you can assume "document" has no punctuation #e.g. document = "He is vice president and he can be president", no period or commas #The function outputs a dictionary # whose keys are included words, in lower cases, and in alphabetical order # whose values are counts of the words #In the above e.g., # output = {'and': 1, 'be': 1, 'can': 1, 'he': 2, 'is': 1, 'president': 2, 'vice': 1} # #Complete the function following the comments and upload to Vocareum # ATTENTION!: upload just the complete function # with the function name countWords # and the file name EX6_16.py, # # ----- start the code here ------ #Split document into a list named "words", each element in lower case

#create an empty dictionary named "wordCounts"

#for each word in words, increment its count in the dictionary

#Sort the dictionary keys and put them into an extra list.

#create a dictionary wordcount2 with the keys sorted

#Return return wordCounts2

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

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions

Question

What is (a) an extraneous variable? (b) confounding variable?

Answered: 1 week ago

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago