Advertisement
scarygarey

min_max_mean

Jan 12th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #-------------------------------------------------------------------------------
  2. # Name: module2
  3. # Purpose:
  4. #
  5. # Author: DGarey
  6. #
  7. # Created: 12/01/2020
  8. # Copyright: (c) DGarey 2020
  9. # Licence: <your licence>
  10. #-------------------------------------------------------------------------------
  11.  
  12. import random
  13.  
  14. #
  15. # Add your count function here
  16. def count(number, list):
  17. count = 0 # Initialise a variable for counting scores of ten
  18.  
  19. for item in list:
  20. if item == number:
  21. count += 1
  22. return(count)
  23. #
  24.  
  25. scores = []
  26.  
  27. for x in range (0, 30):
  28. scores.append(random.randint(0, 10))
  29.  
  30. print(scores)
  31.  
  32. top_scorers = count(10, scores) # Count function called here
  33.  
  34. print(str(top_scorers) + " learners got top marks")
  35.  
  36. mean_scores = sum(scores)/len(scores)
  37. min_scores = min(scores)
  38. max_scores = max(scores)
  39.  
  40. print("Average =", mean_scores, " minimum score = ", min_scores, " maximum score = ", max_scores)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement