Advertisement
brendan-stanford

score_count

Aug 21st, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. from random import randint
  2.  
  3. #function checks for given score and increases mark counter for eventual return after completion
  4. def mark_count(score_list, grade):
  5. mark = 0
  6. for score in score_list:
  7. if score == grade:
  8. mark += 1
  9. return mark
  10.  
  11. #list stores randomly generated scores
  12. scores = []
  13.  
  14. for x in range(0, 30):
  15. scores.append(randint(0,10))
  16.  
  17. #Scores are printed and mark_count is called
  18. print(scores)
  19.  
  20. grades = mark_count(scores, 5)
  21.  
  22. print("{0} learners got input mark".format(grades))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement