-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrading.py
More file actions
52 lines (45 loc) · 1.25 KB
/
Grading.py
File metadata and controls
52 lines (45 loc) · 1.25 KB
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
from collections import defaultdict
from scipy.stats import rankdata
import pandas as pd
print('SAVE')
container = defaultdict(list)
num = int(input('Number of students: '))
courses = int(input('Courses: '))
for i in range(num):
name = input('Name: ')
for j in range(courses):
score = int(input('Score: '))
container[name].append(score)
#Grade
def grade(D):
newD = defaultdict(list)
for i in D:
L = D[i]
for j in L:
if j >=80:
newD[i].append('A -> Excellent')
elif 60<j<79:
newD[i].append('B -> Very Good')
elif 40<j<59:
newD[i].append('C -> Good')
elif 29<j<39:
newD[i].append('D -> Pass')
else:
newD[i].append('E-F -> Fail')
return newD
#Rankings
def rank(D):
total = defaultdict(list)
for i in D:
L = D[i]
sumJ = 0
for j in L:
sumJ += int(j)
total[i].append(sumJ)
df = pd.DataFrame(dict(total)).T
df.columns = ['Total_Score']
df['Position'] = df['Total_Score'].rank(method='min',ascending=False)
return df
print(container)
print(grade(container))
print(rank(container))