Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- #
- # Add your count function here
- #
- def count(mark,scores):
- numberOfOcur = 0
- for i in scores:
- if i == mark:
- numberOfOcur += 1
- return numberOfOcur
- # This function sums the items of a list.
- def sumList(list):
- newsum = 0
- for i in list:
- newsum = newsum + i
- return newsum
- scores = []
- for x in range (0, 30):
- scores.append(random.randint(0, 10))
- print(scores)
- top_scorers = count(10, scores) # Count function called here
- # Define a list in which we have the number
- # of occurences with scores less than 5.
- # At the beginning we set all to 0.
- down_scorers = [0,0,0,0,0]
- #Count the occurence of the scores and save it in the list.
- for i in range(len(down_scorers)):
- down_scorers[i] = count(i,scores)
- print("{0} learners got top marks".format(top_scorers))
- print("{0} learners not reached the half of the score.".format(sumList(down_scorers)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement