A comprehensive Python-based student management system for tracking student records, marks, and generating class statistics.
- ✅ Add Student Records - Register new students with ID, name, and marks
- ✅ View All Students - Display all student records in a formatted table
- ✅ Search Student - Find student records by ID
- ✅ Class Statistics - Generate comprehensive statistics with:
- Recursive average calculation
- Highest/lowest marks using list comprehensions
- Tied marks handling (displays all students with same marks)
- ✅ Update Student Marks - Modify existing student marks
- ✅ Edit Student Name - Modify an existing student's name
- ✅ Delete Student Records - Remove student records with confirmation
- Custom Context Manager -
FileManagerfor efficient file handling - Custom Exceptions -
DuplicateIDErrorandInvalidMarkErrorfor robust error handling - Input Validation - Comprehensive validation for student IDs, names, and marks
- Recursive Functions - Average calculation using recursion
- List Comprehensions - Finding students with highest/lowest marks
- CSV File Storage - Persistent data storage using CSV format
student_system/
├── main.py # Main application with menu and CRUD operations
├── utils.py # Utility functions, validators, and custom classes
└── students.txt # CSV file for storing student records
- Python 3.x
- No external dependencies (uses only standard library)
-
Clone the repository
git clone https://github.com/Abhey518/python-student-grade-system.git cd python-student-grade-system -
Navigate to the student_system directory
cd student_system -
Run the application
python main.py
1. Add Student Record
2. View All Student Information
3. Search Student by ID
4. Class Statistics
5. Update Student Marks
6. Edit Student Name
7. Delete Student Record
8. Exit
- Format:
S001,S002,S003, etc. - Must start with 'S' followed by 3 digits
- Case insensitive (accepts both
s001andS001)
- Valid range: 0-100 (integers only)
- Subjects: Science and Maths
- A+: 90-100
- A: 75-89
- B: 65-74
- C: 55-64
- S: 45-54
- F: Below 45
Enter Student ID (format: S001): S001
Enter Student Name: Alice Johnson
Enter Science Marks (0-100): 85
Enter Maths Marks (0-100): 90
Total Students: 4
SCIENCE STATISTICS:
Average Marks: 85.00
Highest: 95
- S003 - Charlie
Lowest: 75
- S002 - Bob
MATHS STATISTICS:
Average Marks: 80.00
Highest: 90 (Tied - 2 students)
- S001 - Alice
- S004 - David
Lowest: 70
- S003 - Charlie
The system validates:
- ✅ Student ID format (S + 3 digits)
- ✅ Duplicate student IDs
- ✅ Empty student names
- ✅ Marks range (0-100)
- ✅ Integer marks only
- FileNotFoundError - Handles missing student records file
- DuplicateIDError - Prevents duplicate student IDs
- InvalidMarkError - Validates marks range
- AssertionError - Catches validation failures
- ValueError - Handles non-integer mark inputs
- Student ID format: S001, S002, etc. (S followed by 3 digits)
- Student names and marks can be updated; student IDs cannot be changed
class FileManager:
"""Custom context manager for file handling"""
def __enter__(self):
# Open file
def __exit__(self, exc_type, exc_value, exc_traceback):
# Close filedef calculate_average(marks, index=0, total=0):
"""Recursive function to calculate average marks"""
if index == len(marks):
if len(marks) == 0:
return 0
return total / len(marks)
return calculate_average(marks, index + 1, total + marks[index])highest_science_mark = max(science_marks)
highest_science_students = [s for s in students if s['Science'] == highest_science_mark]Student records are stored in CSV format:
Student_ID,Student_Name,Science,Maths
S001,Alice Johnson,85,90
S002,Bob Smith,75,80This project is licensed under the MIT License - see the LICENSE file for details.
Arunoda Abeywardhana
- GitHub: @Abhey518
This is an individual academic project developed as part of the coursework requirements.
- Course: CTEC 31042 - Python Programming
- Semester: V
- Project Type: Individual Mini Project
Note: This system is designed for educational purposes and demonstrates Python programming concepts including file I/O, custom exceptions, context managers, recursion, and list comprehensions.