Advertisement
KaySawbridge

Mean function

Jul 27th, 2020
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. import random
  2.  
  3. #mean function
  4. def mean_func(values):
  5.     length = len(values)
  6.     total_values = 0
  7.     total_sum=sum(values)
  8.     average =total_sum/length        
  9.    
  10.     return average
  11.  
  12. scores = []
  13.  
  14. for x in range (0, 100):
  15.   scores.append(random.randint(0, 100))  #generate the list of scores
  16.  
  17. print(scores)
  18.  
  19. average_score = mean_func(scores)
  20.  
  21. print("The average score is",average_score,)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement