Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import *
- #function to count the number of instances of a nominated score
- def countscores(scores,scoretocount):
- counter=0
- for score in scores:
- if score == scoretocount:
- counter +=1
- return scoretocount, counter #return the nominated score
- scores=[]
- for x in range(0,30):
- scores.append(randint(0,10)) #generate a random number from 0 to 10
- print(scores)
- scoretocount = input("what score are you interested in: " )
- topscorers = countscores(scores, int(scoretocount))
- print(str(topscorers[1]) + " learners scored " + str(topscorers[0])+ " marks")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement