def printSummary(theTable): """ printSummary prints a summary of information about the hash table contents. printSummary : HashTable -> NoneType """ # Display the entire table! print("Unique words:", theTable.size) # Find the most common word in the text file. total = 0 maxWord = "" maxCount = 0 for key in keys(theTable): thisCount = get(theTable, key) total += thisCount if thisCount > maxCount: maxCount = thisCount maxWord = key print("There are " + str(len(keys(theTable))) + " words.") print("Total words:", total) print('"' + maxWord + "\" appeared ", str(maxCount), " times, more than any other word.") print('Imbalance =', imbalance(theTable)) print('Load =', load(theTable)) print('Size =', len(theTable.table))
def printSummary( theTable ): """ printSummary prints a summary of information about the hash table contents. printSummary : HashTable -> NoneType """ # Display the entire table! print( "Unique words:", theTable.size ) # Find the most common word in the text file. total = 0 maxWord = "" maxCount = 0 for key in keys( theTable ): thisCount = get( theTable, key ) total += thisCount if thisCount > maxCount: maxCount = thisCount maxWord = key print( "There are " + str( len( keys( theTable ) ) ) + " words." ) print( "Total words:", total ) print( '"' + maxWord + "\" appeared ", str( maxCount ), " times, more than any other word." )
def printTable( hTable ): """ Print the contents of the given hash table. Each key/value pair is displayed in parentheses, tuple-style. All pairs appear on a single line. printTable : HashTable -> NoneType """ print( "Word Count Data ---------------" ) lcount = 0 ltext = 0 for key in keys( hTable ): # print( "(" + key + "," + str( get( hTable, key ) ) + ")", end=" " ) txt = "(" + key + "," + str( get( hTable, key ) ) + ")" ltext += len( txt ) if ltext > 51: print( txt ) ltext = 0 else: print( txt, end=" " ) print()
def printTable(hTable): """ Print the contents of the given hash table. Each key/value pair is displayed in parentheses, tuple-style. All pairs appear on a single line. printTable : HashTable -> NoneType """ print("Word Count Data ---------------") lcount = 0 ltext = 0 for key in keys(hTable): # print( "(" + key + "," + str( get( hTable, key ) ) + ")", end=" " ) txt = "(" + key + "," + str(get(hTable, key)) + ")" ltext += len(txt) if ltext > 51: print(txt) ltext = 0 else: print(txt, end=" ") print()