Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- #function that checks if input grade (a string) is found, which will increase mark and eventually return
- def mark_count(score_list, grade):
- mark = 0
- for score in score_list:
- if score == grade:
- mark += 1
- return mark
- #empty list holds randomly generated alphabetical grades from list below; randint used as random list index
- scores = []
- alphabet = ["a", "b", "c+", "c", "c-", "i"]
- for x in range(0, 30):
- chance = randint(0, 5)
- scores.append(alphabet[chance])
- #print scores and call function
- print(scores)
- grades = mark_count(scores, "b")
- print("{0} learners got input mark".format(grades))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement