-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhys Final Grade Calc.py
63 lines (58 loc) · 1.85 KB
/
Phys Final Grade Calc.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import csv
import Tkinter, tkFileDialog
import numpy as np
#from iPython import embed
#embed()
root = Tkinter.Tk()
root.withdraw()
results = []
file_path = tkFileDialog.askopenfilename()
with open(file_path) as csvfile:
creader = csv.reader(csvfile)
skip = next(creader)
data = [map(float, l) for l in creader]
# [{k:float(d[k]) for k in d} for d in data] #convert values to floats
# data = np.genfromtxt(csvfile, dtype = None, delimiter = ',')
# reader = csv.DictReader(csvfile, quotechar=',',
# quoting=csv.QUOTE_MINIMAL)
#print data
for i in range(len(data)):
homework_array = np.array(data[i][0])
for a in range(1,12):
homework_array = np.append(homework_array, data[i][a])
quiz_array = np.array(data[i][12])
for a in range(13,21):
quiz_array = np.append(quiz_array, data[i][a])
exam_array = (np.array(data[i][21]))
exam_array = np.append(exam_array, data[i][22])
exam_array = np.append(exam_array, data[i][23])
final = data[i][24]
hw_total = 0
quiz_total = 0
exam_total = 0
for j in range(0,12):
hw_total += homework_array[j]
quiz_array = np.sort(quiz_array)
for j in range(2,9):
quiz_total += quiz_array[j]
exam_array = np.sort(exam_array)
hw_percent = hw_total / 240
quiz_percent = quiz_total / 70
#print "Average homework percentage: "
#print hw_percent
#print homework_array
#print "Average quiz percentage:"
#print quiz_percent
#print quiz_array
exam1_percentage = exam_array[0] / 50
exam2_percentage = exam_array[1] / 50
#print exam_array
exam3_percentage = exam_array[2] / 50
final_percentage = final / 50
final_grade = 25 * hw_percent + 15 * quiz_percent + exam1_percentage * 10 + exam2_percentage * 15 + exam3_percentage * 15 + final_percentage * 20
print ('Final grade: ')
print final_grade
#print homework_array
#print quiz_array
#print exam_array
#print final