Advertisement
jhoward48

Untitled

Dec 14th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. #Week two, Test scores using the count function
  2. import random
  3. scores=[]
  4.  
  5. for x in range(0,30):
  6.           scores.append(random.randint(0,10))
  7.           scores.sort()
  8. print(scores)
  9.  
  10. def test_scores(Stud_numbers, scores):
  11.    numbers=0
  12.    for score in scores:
  13.         if score==Stud_numbers:
  14.           numbers= numbers+1  
  15.    print (" {0} pupils got {1} mark".format(numbers, Stud_numbers))  
  16.          
  17. for Stud_numbers in range(0,11):      
  18.      test_scores(Stud_numbers, scores)
  19.  
  20. # i don't fully understand this, i cheated by looking at somebody elses.
  21. # i don't understand why numbers is not just 0 to 10 and gives the actual number of
  22. #students who got that score.  line 15 i understand how it reads the text string, but dont undersand how stud_
  23. #numbers is giving the pupil mark and that numbers is givinng the number of pupils.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement