Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. import matplotlib.pyplot as plot
  2. import random
  3.  
  4. #The counting function.
  5. def count(mark,scores):
  6.     numberOfOcur = 0
  7.     for i in scores:
  8.         if i == mark:
  9.             numberOfOcur += 1
  10.     return numberOfOcur
  11.  
  12.  
  13. # Define the scores
  14. scores = []
  15.  
  16. for x in range (0, 3000):
  17.   scores.append(random.randint(0, 10))
  18.  
  19. # Define the performances
  20. performance = [0,0,0,0,0,0,0,0,0,0,0]
  21.  
  22. #Count the occurence of the scores and save it in the list.
  23. for i in range(len(performance)):
  24.     performance[i] = count(i,scores)
  25.  
  26. print(performance)
  27.  
  28. plot.bar(range(len(performance)), performance, align='center', alpha=0.5)
  29.  
  30. plot.xticks(range(len(performance)))
  31. plot.ylabel('Score frequency')
  32. plot.title('Scores on a quiz')
  33.  
  34. plot.show()
  35. plot.savefig("QuizChart.pdf")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement