Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- import matplotlib.pyplot as plot
- # My function
- def count(item, scores):
- count = 0
- for score in scores:
- if score == item:
- count += 1
- return count
- # End of my function
- # Generate a 30 random numbers from 0 to 10 and append to scores
- scores = []
- for x in range (0, 30):
- scores.append(randint(0, 10))
- print(scores)
- scores_count = []
- for score in range(0,11):
- scores_count.append(count(score, scores))
- plot.bar(range(11), scores_count, align='center', alpha=0.5)
- plot.xticks(range(11))
- plot.ylabel('Score frequency')
- plot.title('Scores on a quiz')
- plot.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement