-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathregression.py
More file actions
32 lines (22 loc) · 965 Bytes
/
regression.py
File metadata and controls
32 lines (22 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# should return a hash with the average values on its first index, then individual scores on each other index
def run(student_hash):
ids = student_hash.keys()
num_questions = calc_num_questions(student_hash, ids)
build = []
avg_hash = get_avg_hash(student_hash, 1, num_questions, []) #answers should be found on odd numbers
print(student_hash) #this will print a lot depending on the file
def calc_num_questions(student_hash, ids):
return len(student_hash[ids[0]]) / 2
def get_avg_hash(student_hash, answer, num_questions, avg_hash):
if answer <= num_questions:
avg_hash.append(calc_avg(student_hash, answer))
answer += 2
get_avg_hash(student_hash, answer, num_questions, avg_hash)
else:
print(avg_hash)
return avg_hash[:]
def calc_avg(student_hash, answer):
sum = 0
for arr in student_hash:
sum += float(student_hash[arr][answer])
return sum / len(student_hash)