Advertisement
brendan-stanford

scores_mean

Aug 22nd, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. from random import randint
  2.  
  3. #list stores randomly generated scores and length sets number of scores to generate
  4. scores = []
  5. length = int(input("Number of scores:"))
  6.  
  7. #creates dataset and appends to scores list
  8. def data_set(size):
  9. for x in range(size):
  10. values = randint(0, 10)
  11. scores.append(values)
  12.  
  13. #calls dataset function based on specified length and calculates corresponding mean
  14. def mean(dataset):
  15. data_set(length)
  16. total = 0
  17. for i in dataset:
  18. total += i
  19. avg = total/length
  20. return avg
  21.  
  22. #calls mean function with scores list and prints mean and dataset for inspection
  23. average = mean(scores)
  24. print("The mean score is:" + str(average))
  25. print(scores)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement