Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. import random
  2.  
  3. scores = []
  4.  
  5. for x in range (0, 30):
  6.   scores.append(random.randint(0, 10))
  7.  
  8. def count(threshold, scores):
  9.     top_scores = []
  10.     for i in scores:
  11.         if i >= threshold:
  12.             top_scores.append(i)
  13.     count = len(top_scores)
  14.     return count
  15.  
  16. def countSpecific(specific, scores):
  17.     specificCount = []
  18.     for i in scores:
  19.         if i == specific:
  20.             specificCount.append(i)
  21.     count = len(specificCount)
  22.     return count    
  23.  
  24. print(scores)
  25. print("{0} learners got top marks".format(count(10, scores)))
  26. print("{0} learners got a 7".format(countSpecific(7, scores)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement