-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasc_cpi.py
More file actions
33 lines (27 loc) · 777 Bytes
/
asc_cpi.py
File metadata and controls
33 lines (27 loc) · 777 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
33
import numpy as np
from bs4 import BeautifulSoup
f = open('asc.html')
grade_dict = {'AA': 10, 'AB': 9, 'BB': 8, 'BC': 7,
'CC': 6, 'CD': 5, 'DD': 4, 'FR': 0, 'PP': 1}
soup = BeautifulSoup(f, 'html.parser')
l = []
for i in soup.findAll('table', {'class': 'ss'}):
for j in i.findAll('td'):
l.append(j.text)
# for i in l[1::6]:
# print(i)
def cpi(l):
my_cpi = 0
total_credits = 0
for i, j in zip(l[2::6], l[4::6]):
if j.strip() == 'FR':
continue
my_cpi += float(i) * float(grade_dict[j.strip()])
total_credits += float(i)
print(float(i) , float(grade_dict[j.strip()]))
my_cpi = my_cpi/total_credits
print(total_credits)
print(my_cpi)
return my_cpi
cpi(l)
print(len(l[::6]))