SHARE
TWEET

Untitled

chris8900 Aug 14th, 2019 51 in 22 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2. import matplotlib.pyplot as plot
  3.  
  4. def tally(maxMark,containingList):
  5.     totals = [0]* (maxMark + 1)
  6.     for val in containingList:
  7.         totals[val] += 1
  8.     return totals
  9.  
  10. #set up scores
  11. scores = []
  12. for x in range (0, 30):
  13.   scores.append(random.randint(0, 10))
  14.  
  15. print(scores)
  16.  
  17. distribution = tally(10,scores)
  18. print("Distribution of marks : {0}".format(distribution))
  19.  
  20. # plot the distribution
  21. plot.bar(range(11), distribution, align='center', alpha=0.5)
  22. plot.xticks(range(11))
  23. plot.ylabel('Score frequency')
  24. plot.title('Marks in test')
  25.  
  26. plot.show()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top