Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6 . A simple word count! Loop through the passage of text below and store each word in a dictionary that has a key:value pair

6. A simple word count! Loop through the passage of text below and store each word in a dictionary that has a key:value pair of word: # of occurrences (for example: there are 10 occurrences of 'the' in the passage, one dictionary entry would be 'the': 10)text_list =['Python', 'was', 'conceived', 'in', 'the', 'late', '1980s', 'and', 'its', 'implementation', 'began', 'in', 'December', '1989','by', 'Guido', 'van', 'Rossum', 'at', 'Centrum', 'Wiskunde', '&', 'Informatica', 'in', 'the', 'Netherlands', 'as','a', 'successor', 'to', 'the', 'ABC', 'language', 'itself', 'inspired', 'by', 'SETL', 'capable', 'of', 'exception', 'handling', 'and', 'interfacing', 'with', 'the', 'Amoeba', 'operating', 'system', '.', 'Van', 'Rossum', 'remains', "Python's", 'principal', 'author', '.', 'His', 'continuing', 'central', 'role', 'in', "Python's", 'development', 'is', 'reflected', 'in', 'the', 'title', 'given', 'to', 'him', 'by', 'the', 'Python', 'community', 'Benevolent', 'Dictator', 'For', 'Life', '.','On', 'the', 'origins', 'of', 'Python', 'Van', 'Rossum', 'wrote', 'in','1996','In', 'December', '1989','I', 'was', 'looking', 'for', 'a', 'hobby', 'programming', 'project', 'that', 'would', 'keep', 'me', 'occupied', 'during', 'the', 'week', 'around', 'Christmas', '.','My', 'office', 'would', 'be', 'closed', 'but', 'I', 'had', 'a', 'home', 'computer', 'and', 'not', 'much', 'else', 'on','my', 'hands', '.','I', 'decided', 'to', 'write', 'an', 'interpreter', 'for', 'the', 'new', 'scripting', 'language', 'I', 'had', 'been', 'thinking', 'about', 'lately', 'a', 'descendant', 'of', 'ABC', 'that', 'would', 'appeal', 'to', 'Unix/C', 'hackers', '.','I', 'chose', 'Python', 'as','a', 'working', 'title', 'for', 'the', 'project', 'being', 'in','a', 'slightly', 'irreverent', 'mood', 'and', 'a', 'big', 'fan', 'of', 'Monty', "Python's", 'Flying', 'Circus', '.']7. Loop through the dictionary you made above of {word: # of occurrences}, sum up the total number of words and divide each entry in the dictionary by that total sum and store it in a new dictionary (this will take 2 separate loops!)(In data science this is called Term-Frequency or TF)Extra challenge: Sort the output by the TF in descending order.

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

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago