JAS_Software

Count Scores

Apr 25th, 2021 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. from random import randint
  2.  
  3. def getScores():
  4.     scores = []
  5.     for i in range(0,30):
  6.         score = randint(1,10)
  7.         scores.append(score)
  8.     return scores
  9.  
  10. def countStat(scores,stat):
  11.     count = 0
  12.     for score in scores:
  13.         if score == stat:
  14.             count += 1
  15.     return count
  16.    
  17. def getStats(scores):
  18.     stats = []
  19.     for stat in range(1,11):
  20.         count = countStat(scores,stat)
  21.         stats.append(count)
  22.     return stats
  23.  
  24. def printStats(stats):
  25.     score = 1
  26.     for stat in stats:
  27.         print(str(stat) + " leaners achieved a score of " + str(score))
  28.         score = score + 1
  29.  
  30. scores = getScores()
  31. stats = getStats(scores)
  32. print(scores)
  33. printStats(stats)
  34.  
  35.  
Add Comment
Please, Sign In to add comment