Student Marks Management System
This project is a Python-based Student Marks Management System. It reads student names and marks from a text file, calculates the total and average marks, assigns grades, and displays the results.
The original program contained several bugs. The bugs were identified, corrected, tested, and documented as part of the Week 2 debugging and troubleshooting task.
Week_2_Debugging_Task/
│
├── student_marks.py
├── students.txt
└── debugging_log.md
This is the corrected and refactored Python program. It performs the following operations:
- Reads student records from
students.txt. - Calculates the total marks.
- Calculates the average using the correct number of subjects.
- Assigns grades based on the average.
- Displays the results of all valid students.
- Handles missing files safely.
- Detects invalid and non-numeric marks.
- Rejects marks outside the range of
0to100. - Skips malformed student records without stopping the program.
This file contains the student information in the following format:
StudentName,Mark1,Mark2,Mark3,Mark4,Mark5
Example:
Manasa,85,90,78,88,95
Rahul,70,75,80,65,72
Ananya,95,92,90,96,94
This file contains the complete debugging documentation, including:
- Bugs identified in the original program.
- Original incorrect code.
- Corrected code.
- Causes of the errors.
- Debugging steps.
- Testing details.
- Expected and actual results.
- Refactoring and improvements.
The following issues were identified and corrected:
- Incorrect average calculation.
- Last student record being skipped.
- Incorrect grade boundary conditions.
- Missing file handling.
- Invalid non-numeric marks.
- Marks outside the valid range.
- Unsafe file handling and weak program structure.
- Python 3.x
- Visual Studio Code or another Python-compatible editor
- Open the project folder in Visual Studio Code.
- Open the terminal in the project folder.
- Make sure
student_marks.pyandstudents.txtare in the same folder. - Run the following command:
py student_marks.pyStudent Marks Management System
===== STUDENT RESULTS =====
Name: Manasa
Marks: [85, 90, 78, 88, 95]
Total: 436
Average: 87.2
Grade: B
---------------------------
Name: Rahul
Marks: [70, 75, 80, 65, 72]
Total: 362
Average: 72.4
Grade: C
---------------------------
Name: Ananya
Marks: [95, 92, 90, 96, 94]
Total: 467
Average: 93.4
Grade: A
---------------------------
The program was tested using the following conditions:
- Normal execution with valid student records.
- Correct average calculation.
- Display of the final student record.
- Missing
students.txtfile. - Non-numeric marks such as
abc. - Marks greater than
100. - Restoration of valid input data after testing.
All the performed tests produced the expected results.
The Student Marks Management System was successfully debugged and improved. The corrected program now calculates results accurately, handles invalid input safely, processes every student record, and provides clear error and warning messages.