Advertisement
ceiszele

Scores

Dec 14th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. from random import *
  2.  
  3. #function to count the number of instances of a nominated score
  4. def countscores(scores,scoretocount):
  5. counter=0
  6. for score in scores:
  7. if score == scoretocount:
  8. counter +=1
  9. return scoretocount, counter #return the nominated score
  10.  
  11. scores=[]
  12. for x in range(0,30):
  13. scores.append(randint(0,10)) #generate a random number from 0 to 10
  14. print(scores)
  15.  
  16. scoretocount = input("what score are you interested in: " )
  17. topscorers = countscores(scores, int(scoretocount))
  18. print(str(topscorers[1]) + " learners scored " + str(topscorers[0])+ " marks")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement