Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # creates a list containing the numbers of learners who scored each test result from 0 through to 10.
- import matplotlib.pyplot as plot
- from random import randint
- # Add your count function here
- def count (num,scores1):
- i = 0
- for item in scores1:
- if item == num:
- i +=1
- return i
- scores = [randint(0, 10) for x in range (30) ]
- # Generate a random number from 0 to 10 and append to scores
- print(scores)
- performance =[]
- def performance_li(scores):
- t = 0
- while t != 11:
- item =count(t, scores) # Count function called here
- performance.append(item)
- t = t +1
- performance_li(scores)
- print (performance)
- plot.bar(range(11), performance, align='center', alpha=0.5)
- plot.xticks(range(11))
- plot.ylabel('Score frequency')
- plot.title('Scores on a quiz')
- plot.show()
- plot.savefig(fname="Quiz Chart.png")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement