Advertisement
KaySawbridge

Counting top scores

Jul 27th, 2020 (edited)
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. import random
  2.  
  3. #Count function
  4. def count_func(list_element,item_list):
  5.     count = 0
  6.     for item in item_list:
  7.         if list_element == item:
  8.             count += 1
  9.     return count
  10.    
  11. scores = [] #creates an empty list
  12.  
  13. for x in range (0, 30): #30 studenst
  14.   scores.append(random.randint(0, 10))  #assigns scores to the students
  15.  
  16. print(scores)
  17.  
  18. top_scorers = count_func(10,scores) #calls the count function to check the number of 10s
  19.  
  20. print("{0} learners got top marks".format(top_scorers))
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement