Advertisement
Mori007

GraphTopscore

May 10th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import matplotlib.pyplot as plot
  2. from random import randint
  3.  
  4. scores = []
  5. test_result = []
  6.  
  7. def count(num,scores):
  8. number = num
  9. count = 0
  10. for i in scores:
  11. if(i == number):
  12. count += 1
  13. return count
  14.  
  15. for x in range (0, 30):
  16. scores.append(randint(0, 10)) # Generate a random number from 0 to 10 and append to scores
  17.  
  18. print(scores)
  19. counter = 0
  20.  
  21. for j in range(11):
  22. test_result.append(count(counter,scores))
  23. counter+= 1
  24. print(test_result)
  25.  
  26. plot.bar(range(11), test_result, align='center', alpha=0.5)
  27.  
  28. plot.xticks(range(11))
  29. plot.ylabel('Number of learners')
  30. plot.title('Test result')
  31.  
  32. plot.show()
  33. plot.savefig(fname="Quiz Chart.png")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement