-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpa.py
65 lines (57 loc) · 1.43 KB
/
gpa.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
64
65
f = open("score.txt", "r", encoding="UTF-8")
def avg():
grade = 0
credit = 0
for s in f:
t = s.split()
# if '校公选课' in t:
# continue
# if '体育课' in t:
# continue
# if '2021-2022-1' not in t:
# continue
print(t)
credit += float(t[5])
grade += float(t[4]) * float(t[5])
print("avg", grade / credit)
print("credit", credit)
def gpa():
grade = 0
credit = 0
gpa = 0
for s in f:
t = s.split()
# if '校公选课' in t:
# continue
# if '体育课' in t:
# continue
# if '2021-2022-1' not in t:
# continue
print(t)
credit += float(t[5])
point = 0
if float(t[4]) >= 90:
point = 4.0
elif float(t[4]) >= 85:
point = 3.7
elif float(t[4]) >= 82:
point = 3.3
elif float(t[4]) >= 78:
point = 3.0
elif float(t[4]) >= 75:
point = 2.7
elif float(t[4]) >= 72:
point = 2.3
elif float(t[4]) >= 68:
point = 2.0
elif float(t[4]) >= 64:
point = 1.5
elif float(t[4]) >= 60:
point = 1.0
grade += float(t[4]) * float(t[5])
gpa += point * float(t[5])
print("avg", grade / credit)
print("gpa", gpa / credit)
print("credit", credit)
gpa()
f.close()