-
Notifications
You must be signed in to change notification settings - Fork 0
/
_23Json.py
23 lines (22 loc) · 896 Bytes
/
_23Json.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import json
import glob
def print_scores(dirname):
scores = {}
for filename in glob.glob(f'{dirname}/*.json'):
scores[filename] = {}
with open(filename) as infile:
for result in json.load(infile):
for subject, score in result.items():
scores[filename].setdefault(subject,
[])
scores[filename][subject].append(score)
for one_class in scores:
for subject, subject_scores in scores[one_class].items():
min_score = min(subject_scores)
max_score = max(subject_scores)
average_score = (sum(subject_scores) /
len(subject_scores))
print(subject)
print(f'\tmin {min_score}')
print(f'\tmax {max_score}')
print(f'\taverage {average_score}')