Day 28 – OOP Mini Project: Student Management System
Project: Build a complete Student Management System that demonstrates class design, encapsulation, and data management using OOP principles.
01. Project Goal
By the end of this project, you will be able to:
- Design and implement multiple interacting classes
- Manage a list of objects efficiently
- Apply encapsulation using private attributes and properties
- Perform CRUD operations (Create, Read, Update, Delete) on objects
02. System Design
We will build two main classes:
1️⃣ Student
Represents individual students.
-
Attributes:
name,student_id,grade -
Methods:
-
introduce()→ print student details -
grade(property) → getter and setter with validation
-
2️⃣ StudentManager
Handles the list of all students.
-
Attributes:
-
students→ a list storingStudentobjects
-
-
Methods:
-
add_student()→ add new student -
remove_student()→ remove by student ID -
print_all()→ display all students
-
03. Implementation
class Student:
def __init__(self, name, student_id, grade):
self.name = name
self.student_id = student_id
self.__grade = grade # Private attribute
@property
def grade(self): # Getter
return self.__grade
@grade.setter
def grade(self, value): # Setter with validation
if value in ["A", "B", "C", "D", "F"]:
self.__grade = value
else:
print("Invalid grade")
def introduce(self):
print(f"Name: {self.name}, ID: {self.student_id}, Grade: {self.__grade}")
class StudentManager:
def __init__(self):
self.students = [] # Store multiple students
def add_student(self, student):
self.students.append(student)
print(f"Student {student.name} added.")
def remove_student(self, student_id):
self.students = [s for s in self.students if s.student_id != student_id]
print(f"Student with ID {student_id} removed.")
def print_all(self):
print("=== Student List ===")
for s in self.students:
s.introduce()
04. Example Usage
# Create the manager
manager = StudentManager()
# Add students
s1 = Student("Sabin", "S001", "A")
s2 = Student("Anna", "S002", "B")
s3 = Student("Tom", "S003", "C")
manager.add_student(s1)
manager.add_student(s2)
manager.add_student(s3)
# Print all students
manager.print_all()
# Update grade
s2.grade = "A"
manager.print_all()
# Remove a student
manager.remove_student("S003")
manager.print_all()
05. Expected Output
Student Sabin added.
Student Anna added.
Student Tom added.
=== Student List ===
Name: Sabin, ID: S001, Grade: A
Name: Anna, ID: S002, Grade: B
Name: Tom, ID: S003, Grade: C
=== Student List ===
Name: Sabin, ID: S001, Grade: A
Name: Anna, ID: S002, Grade: A
Name: Tom, ID: S003, Grade: C
Student with ID S003 removed.
=== Student List ===
Name: Sabin, ID: S001, Grade: A
Name: Anna, ID: S002, Grade: A
06. Key Concepts Used
| Concept | Description |
|---|---|
| Encapsulation | Protected grade attribute using a private variable and property. |
| Property Decorators | Used @property and setter for controlled access. |
| Class Interaction |
StudentManager manages multiple Student objects. |
| List Comprehension | Used to filter students during removal. |
07. Reflection
You have now completed the basics section of your Python journey 🎉
You learned how to:
- Model real-world entities using classes and objects
- Apply encapsulation, inheritance, and properties
- Design structured, maintainable OOP systems
- Combine all these ideas into a working mini project
Congratulations! You’ve completed the Python Fundamentals (Days 1–28) 🎯
Top comments (0)