Skip to content

Latest commit

 

History

History
82 lines (51 loc) · 1.82 KB

File metadata and controls

82 lines (51 loc) · 1.82 KB

Debugging Log — Student Marks Management System

BUG-01: Incorrect Average Calculation

1. Problem Description

The program calculates the student average incorrectly.

2. Steps to Reproduce

  1. Open the Student Marks Management System.
  2. Run the Python program.
  3. Check the average displayed for Manasa.
  4. Compare the displayed average with the manually calculated average.

3. Actual Behavior

The program displays an average of 109.0 for Manasa.

4. Expected Behavior

The program should display an average of 87.2.

5. Root Cause

The program divides the total marks by 4 instead of the actual number of subjects, which is 5.

6. Buggy Code

average = total / 4

7. Debugging Method

The total and average values were inspected during execution to identify the incorrect divisor.

8. Status

Identified — Not Fixed Yet.

9. Solution Applied

The hardcoded divisor was replaced with len(marks) to calculate the average based on the actual number of subjects.

10. Corrected Code

total = sum(marks)
average = total / len(marks)

11. Testing Result

Input: Manasa's marks = 85, 90, 78, 88, 95

Expected average: 87.2 Actual average after fix: 87.2

Result: PASS

12. Improvement

Using len(marks) makes the program flexible. If the number of subjects changes, the average calculation will still work correctly.

9. Solution Applied

The loop range was corrected to include every student in the list.

10. Corrected Code

for i in range(len(students)):

11. Testing Result

Input: Three students in students.txt.

Expected result: All three students should be displayed.

Actual result: Manasa, Rahul and Ananya were displayed.

Result: PASS

12. Improvement

The corrected loop processes every valid student index, including the last student.