Advertisement
zhongnaomi

test result

Feb 7th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. # creates a list containing the numbers of learners who scored each test result from 0 through to 10.
  2. import matplotlib.pyplot as plot
  3.  
  4.  
  5.  
  6. from random import randint
  7.  
  8.  
  9.  
  10.  
  11. # Add your count function here
  12. def count (num,scores1):
  13.     i = 0
  14.     for item in scores1:
  15.         if item == num:
  16.             i +=1
  17.     return i
  18.  
  19. scores = [randint(0, 10) for x in range (30) ]
  20. # Generate a random number from 0 to 10 and append to scores
  21.  
  22. print(scores)
  23.  
  24.  
  25. performance =[]
  26. def performance_li(scores):
  27.     t = 0
  28.     while t != 11:
  29.        
  30.         item =count(t, scores)  # Count function called here
  31.         performance.append(item)
  32.         t = t +1
  33.        
  34. performance_li(scores)    
  35. print (performance)
  36.  
  37.  
  38.  
  39.  
  40.  
  41. plot.bar(range(11), performance, align='center', alpha=0.5)
  42.  
  43. plot.xticks(range(11))
  44. plot.ylabel('Score frequency')
  45. plot.title('Scores on a quiz')
  46.  
  47. plot.show()
  48. plot.savefig(fname="Quiz Chart.png")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement