Rakshitjan commited on
Commit
cf44152
·
verified ·
1 Parent(s): 15beb90

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -6
main.py CHANGED
@@ -45,12 +45,10 @@ class Chapter:
45
  self.data[chapter_name]["count"] += 1
46
 
47
  def print_averages(self):
48
- result = {}
49
- for chapter, stats in self.data.items():
50
  if stats["count"] > 0:
51
  avg = stats["sum_marks"] / stats["count"]
52
- result[chapter] = round(avg, 1)
53
- return result
54
 
55
  class PhysicsChapter(Chapter):
56
  pass
@@ -110,8 +108,7 @@ def analyze_chapter_averages():
110
  chapter_name = chapter_name.strip().lower()
111
  marks = row[i + 1]
112
 
113
- if marks and marks.replace('.', '', 1).isdigit(): # Check if marks is a valid number
114
- marks = float(marks)
115
  # Check if the chapter belongs to Physics, Chemistry, or Maths
116
  if chapter_name in physics_chapters:
117
  physics_tracker.add_marks(chapter_name, 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
+ print(f"{chapter}: Average = {round(avg, 1)}")
 
52
 
53
  class PhysicsChapter(Chapter):
54
  pass
 
108
  chapter_name = chapter_name.strip().lower()
109
  marks = row[i + 1]
110
 
111
+ if isinstance(marks, (int, float)):
 
112
  # Check if the chapter belongs to Physics, Chemistry, or Maths
113
  if chapter_name in physics_chapters:
114
  physics_tracker.add_marks(chapter_name, marks)