Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Week 2 Task: Debugging and Troubleshooting Python Applications

Project Title

Student Marks Management System

Project Description

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.

Project Files

Week_2_Debugging_Task/
│
├── student_marks.py
├── students.txt
└── debugging_log.md

1. student_marks.py

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 0 to 100.
  • Skips malformed student records without stopping the program.

2. students.txt

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

3. debugging_log.md

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.

Bugs Fixed

The following issues were identified and corrected:

  1. Incorrect average calculation.
  2. Last student record being skipped.
  3. Incorrect grade boundary conditions.
  4. Missing file handling.
  5. Invalid non-numeric marks.
  6. Marks outside the valid range.
  7. Unsafe file handling and weak program structure.

How to Run the Program

Requirements

  • Python 3.x
  • Visual Studio Code or another Python-compatible editor

Steps

  1. Open the project folder in Visual Studio Code.
  2. Open the terminal in the project folder.
  3. Make sure student_marks.py and students.txt are in the same folder.
  4. Run the following command:
py student_marks.py

Expected Output

Student 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
---------------------------

Testing Performed

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.txt file.
  • 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.

Conclusion

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.

About

A Python Student Marks Management System developed for the Week 2 debugging and troubleshooting task.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages