Answered step by step
Verified Expert Solution
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
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 occurrences of 'the' in the passage, one dictionary entry would be 'the': textlist Python 'was', 'conceived', in 'the', 'late', s 'and', 'its', 'implementation', 'began', in 'December', by 'Guido', 'van', 'Rossum', at 'Centrum', 'Wiskunde', & 'Informatica', in 'the', 'Netherlands', asa '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', inIn 'December', 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', onmy '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 'UnixC 'hackers', I 'chose', 'Python', asa 'working', 'title', 'for', 'the', 'project', 'being', ina 'slightly', 'irreverent', 'mood', 'and', a 'big', 'fan', of 'Monty', "Python's", 'Flying', 'Circus', 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 separate loops!In data science this is called TermFrequency or TFExtra challenge: Sort the output by the TF in descending order.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started