-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschool.py
94 lines (89 loc) · 3 KB
/
school.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
class School:
def __init__(self, name, address) -> None:
self.name = name
self.address = address
self.teachers = {} # {"bangla" : teacher_object}
self.classrooms = {} # {"eight" : classroom_object}
def add_classroom(self, classroom):
self.classrooms[classroom.name] = classroom
def add_teacher(self, subject, teacher):
self.teachers[subject] = teacher
def student_admission(self, student):
classname = student.classroom.name
self.classrooms[classname].add_student(student)
# rahim - bang - 50 - B - 2.00
# - eng - 80 - A+ - 5.00
# ------------------------
# total ----------- - C - 2.00
@staticmethod
def calculate_grade(marks):
if marks>=80 and marks<=100:
return 'A+'
elif marks >= 70 and marks<80:
return 'A'
elif marks >= 60 and marks <70:
return 'A-'
elif marks >= 50 and marks <60:
return 'B'
elif marks >= 40 and marks < 50:
return 'C'
elif marks >= 33 and marks < 40:
return 'D'
else:
return 'F'
@staticmethod
def grade_to_value(grade):
grade_map = {
'A+' : 5.00,
'A' : 4.00,
'A-' : 3.50,
'B' : 3.00,
'C' : 2.00,
'D' : 1.00,
'F' : 0.00
}
return grade_map[grade]
@staticmethod
def value_to_grade(value):
if value >=4.5 and value<=5.00:
return 'A+'
elif value >= 3.5 and value <4.50:
return 'A'
elif value >= 3.0 and value < 3.5:
return 'A-'
elif value >= 2.5 and value < 3.0:
return 'B'
elif value >= 2.0 and value < 2.5:
return 'C'
elif value >= 1.0 and value < 2.0:
return 'D'
else:
return 'F'
def __repr__(self):
# All Classrooms
for key in self.classrooms.keys():
print(key)
# All Students
print("All Students")
result = ''
for key,value in self.classrooms.items(): # prottekta classroom e gelam
result += f"---{key.upper()} Classroom Students\n"
for student in value.students:
result += f"{student.name}\n"
print(result)
# All Subjects
subject = ''
for key,value in self.classrooms.items(): # prottekta classroom e gelam
subject += f"---{key.upper()} Classroom Subjects\n"
for sub in value.subjects:
subject += f"{sub.name}\n"
print(subject)
# All Teachers - Homework
# All Student Results
print("Students Results")
for key,value in self.classrooms.items():
for student in value.students:
for k,i in student.marks.items():
print(student.name,k,i,student.subject_grade[k])
print(student.calculate_final_grade())
return ''