Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. fname = 'f:\\питон\\dataset_3380_5.txt'
  2. ClassQuantity = 11
  3. Table = dict()
  4.  
  5. ArrayOfHeight = [0] * ClassQuantity
  6. ArrayOfAmount = [0] * ClassQuantity
  7.  
  8. InfoFile = open(fname, 'r')
  9. for line in InfoFile:
  10.     s = line.strip().split('\t')
  11.     s[0] = int(s[0])
  12.    
  13.     ArrayOfAmount[s[0] - 1] += 1
  14.     ArrayOfHeight[s[0] - 1] += int(s[2])
  15.    
  16. InfoFile.close()
  17.  
  18. for i in range(ClassQuantity):
  19.     if ArrayOfAmount[i] == 0:
  20.         print(i + 1, '-')
  21.     else:
  22.         print(i + 1, float(ArrayOfHeight[i] / ArrayOfAmount[i]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement