Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -34,6 +34,21 @@ maths_chapters = {
|
|
| 34 |
"three dimensional geometry", "vector algebra", "statistics and probability", "trigonometry"
|
| 35 |
}
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
class Chapter:
|
| 38 |
def __init__(self):
|
| 39 |
self.data = {}
|
|
@@ -45,10 +60,15 @@ class Chapter:
|
|
| 45 |
self.data[chapter_name]["count"] += 1
|
| 46 |
|
| 47 |
def print_averages(self):
|
|
|
|
| 48 |
for chapter, stats in self.data.items():
|
| 49 |
if stats["count"] > 0:
|
| 50 |
avg = stats["sum_marks"] / stats["count"]
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
class PhysicsChapter(Chapter):
|
| 54 |
pass
|
|
|
|
| 34 |
"three dimensional geometry", "vector algebra", "statistics and probability", "trigonometry"
|
| 35 |
}
|
| 36 |
|
| 37 |
+
# class Chapter:
|
| 38 |
+
# def __init__(self):
|
| 39 |
+
# self.data = {}
|
| 40 |
+
|
| 41 |
+
# def add_marks(self, chapter_name, marks):
|
| 42 |
+
# if chapter_name not in self.data:
|
| 43 |
+
# self.data[chapter_name] = {"sum_marks": 0, "count": 0}
|
| 44 |
+
# self.data[chapter_name]["sum_marks"] += marks
|
| 45 |
+
# self.data[chapter_name]["count"] += 1
|
| 46 |
+
|
| 47 |
+
# def print_averages(self):
|
| 48 |
+
# for chapter, stats in self.data.items():
|
| 49 |
+
# if stats["count"] > 0:
|
| 50 |
+
# avg = stats["sum_marks"] / stats["count"]
|
| 51 |
+
# return f"{chapter}: Average = {round(avg, 1)}"
|
| 52 |
class Chapter:
|
| 53 |
def __init__(self):
|
| 54 |
self.data = {}
|
|
|
|
| 60 |
self.data[chapter_name]["count"] += 1
|
| 61 |
|
| 62 |
def print_averages(self):
|
| 63 |
+
averages = {}
|
| 64 |
for chapter, stats in self.data.items():
|
| 65 |
if stats["count"] > 0:
|
| 66 |
avg = stats["sum_marks"] / stats["count"]
|
| 67 |
+
averages[chapter] = round(avg, 1)
|
| 68 |
+
else:
|
| 69 |
+
averages[chapter] = 0
|
| 70 |
+
return averages
|
| 71 |
+
|
| 72 |
|
| 73 |
class PhysicsChapter(Chapter):
|
| 74 |
pass
|