Question: explain each line in details what it can do >>> import sys >>> import re >>> import collections >>> def readFile(filename): fn = open (
>>> import sys >>> import re >>> import collections >>> def readFile(filename): fn = open ( filename , 'r') words = fn. read(). Split(" ") return words >>> def wordCount (contents): return collections.Counter (contents) >>> def topTenWords (wordCountDict): out string = for wordC in wordCountDict.most common (10): out string += wordC [0] + ", out-string = out-string[ :-2] print "Most Common words:"out string >>> def main(): filename - "C: contents readFile (filename) wordCountD1ct = wordcount (contents) topTenWords (wordCountDict) >>> main() Most Common words: and, of, the, to, is, smart, IoT, network, objects, existing
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
