Advertisement
Mori007

GraphTopscore

May 10th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. mport 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("Result of scores : {0}".format(scores))  # Print result and list of scores
  19.  
  20. counter = 0
  21. for j in range(11):
  22.     test_result.append(count(counter,scores))
  23.     counter+= 1
  24. print("Learners got top marks : {0}".format(test_result)) # Print result and list of learners
  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