teromakotero

Bar Chart

May 10th, 2019
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. import matplotlib.pyplot as plot
  2. import random
  3.  
  4. scores = []
  5. test_results = []
  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(random.randint(0, 10))
  17.  
  18. print(scores)
  19. counter = 0
  20. for j in range(11):
  21.   test_results.append(count(counter,scores))
  22.   counter += 1
  23. print(test_results)
  24.  
  25. plot.bar(range(11), test_results, align='center', alpha=0.5)
  26.  
  27. plot.xticks(range(11))
  28. plot.ylabel('Number of learners')
  29. plot.title('Test result')
  30.  
  31. plot.show()
  32. plot.savefig(fname="Quiz Chart.png")
Advertisement
Add Comment
Please, Sign In to add comment