Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plot
- import random
- #The counting function.
- def count(mark,scores):
- numberOfOcur = 0
- for i in scores:
- if i == mark:
- numberOfOcur += 1
- return numberOfOcur
- # Define the scores
- scores = []
- for x in range (0, 3000):
- scores.append(random.randint(0, 10))
- # Define the performances
- performance = [0,0,0,0,0,0,0,0,0,0,0]
- #Count the occurence of the scores and save it in the list.
- for i in range(len(performance)):
- performance[i] = count(i,scores)
- print(performance)
- plot.bar(range(len(performance)), performance, align='center', alpha=0.5)
- plot.xticks(range(len(performance)))
- plot.ylabel('Score frequency')
- plot.title('Scores on a quiz')
- plot.show()
- plot.savefig("QuizChart.pdf")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement