~/paste/11272
~/paste/11272
~/paste/11272

  1. import random
  2.  
  3. dictionary = [word.strip() for word in open('/usr/share/dict/words')]
  4.  
  5. averages = []
  6.  
  7. repeatCount = 100
  8. wordCount = 1000000
  9.  
  10. for i in xrange(repeatCount):
  11.         characters = 0.0
  12.         for j in xrange(wordCount):
  13.                 characters += len(dictionary[random.randint(0, len(dictionary)-1)])
  14.         averages.append(characters/wordCount)
  15.  
  16. overallAverage = sum(averages) / repeatCount
  17.  
  18. print overallAverage
Language: python
Posted by Anonymous at 23 Sep 2013, 03:57:09 UTC