Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- import matplotlib.pyplot as plot
- def count(target,scores):
- counter = 0 # Initialise a variable for counting scores of ten
- for score in scores:
- if score == target:
- counter += 1
- #print("{0} learners got top marks".format(counter))
- return counter
- def count_frequency( to_num, scores_freq):
- for i in range(to_num+1):
- scores_freq.append(count(i,scores))
- scores = []
- scores_freq=[]
- for x in range (0, 30):
- scores.append(randint(0, 10)) # Generate a random number from 0 to 10 and append to scores
- print(scores)
- print(" Num of 10",count(10,scores)) # Count how many scores 10
- count_frequency(10, scores_freq)
- plot.bar(range(11), scores_freq, align='center', alpha=1)
- plot.xticks(range(11))
- plot.ylabel('Score frequency')
- plot.title('Scores on a quiz')
- plot.show()
- plot.savefig(fname="Quiz Chart.png")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement