Word frequency statistics, dictionary sort results

# Statistical word frequency 
from Random Import the randint
 from Collections Import Counter 

DATE = [the randint (. 1, 10) for X in Range (. 1, 21 is )]
 # date1 = {K: the randint (1,50) for K in Range (20 is)} # 20 elements randomly generated dictionary 

Print (DATE) 
C = Counter (DATE)
 Print (C [5])   # number 5 appears statistics 
Print (c.most_common (5))   # statistical frequency of the highest number 5 

# performance statistics 
Sore = {k: randint (60, 100) for k in  " ABCDEFGHIJ "}   # Randomly generates a dictionary Results 
Print (Sore)
 # Print (sore.keys (), sore.values (), sore.items ()) 
Print (sore.items ())                        # list into tuples 
x = sorted (sore.items (), Key = the lambda X: X [. 1])     # sort 
x.reverse ()            # reverse order 
Print (X)

 

Guess you like

Origin www.cnblogs.com/jum-bolg/p/10962173.html