Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import random
  2. from random import randint
  3.  
  4. def count_high(result, test): # Count function defined with 2 arguments.
  5. count = 0
  6. for score in test:
  7. if score == result:
  8. count += 1
  9. return count
  10.  
  11. def count_low(result, test): # Count function defined with 2 arguments.
  12. count = 0
  13. for score in test:
  14. if score <= result:
  15. count += 1
  16. return count
  17.  
  18. scores = []
  19.  
  20. for x in range(0, 30):
  21. scores.append(random.randint(0, 10))
  22.  
  23. print(scores)
  24.  
  25. top_scores = count_high(10, scores) # Count function called here
  26. bottom_scores = count_low(3, scores)
  27.  
  28. print("{0} learners got top marks".format(top_scores))
  29. print("{0} learners got low marks".format(bottom_scores))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement