Student System 🎓📊🏗️
Build a real software project using classes, inheritance, encapsulation and constructors together!
Day 30: Student Management System — You Built Real Software!
30 Days. This Is What You Know Now.
Day 1 you didn't know what a variable was. Today you're building a working software system using classes, inheritance, encapsulation and constructors all at once. That's not learning anymore — that's engineering. Let's build it!
The Parent Class — Person
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def report(self):
print(f"{self.name} is a person.")
Person is the parent. It stores shared information that every person in the system should have. Student and Teacher will both inherit from it.
The Child Classes — Student & Teacher
class Student(Person):
def __init__(self, name, age, score):
super().__init__(name, age)
self.__score = score
def get_score(self):
return self.__score
def report(self):
status = "PASSED" if self.__score >= 50 else "FAILED"
print(f"{self.name} | Score: {self.__score} | {status}")
class Teacher(Person):
def report(self):
print(f"{self.name} is teaching today.")
super().__init__(name, age) sends shared information up to the Person class. __score is private, so it is protected through encapsulation. Both Student and Teacher inherit from Person, but each has its own version of report().
Running the System
people = [
Student("Rohith", 21, 87),
Teacher("Priya", 30)
]
for person in people:
person.report()
Output:
Rohith | Score: 87 | PASSED
Priya is teaching today.
One loop. Two completely different responses. The loop never changes. Each object handles report() in its own way.
What Each Concept Did
__init__ automatically created each object with its data. Inheritance allowed Student and Teacher to reuse functionality from Person. Encapsulation protected __score from direct access. Polymorphism allowed Student.report() and Teacher.report() to behave differently while using the same method name. All four OOP pillars are working together in one system!
Real World Connection
This is exactly how school management software works. A base User class stores common functionality. Student objects add grades and assignments. Teacher objects add subjects and grading tools. Everyone shares the same foundation while keeping their own unique behaviour.
Mini Challenge
Mini Challenge
Create an Admin class that inherits from Person. Override report() so it prints admin information. Add it to the people list and run the loop again. Notice how the loop never changes even when new object types are added. That's the power of polymorphism!
Quick Quiz
Q: What does super().__init__() do? A: It calls the parent's constructor and passes shared data to it.
Q: Why is __score private? A: To protect the data from being changed directly outside the class.
Q: Why does the same report() call produce different outputs? A: Because each class overrides report() with its own behaviour — that's polymorphism.
Phase 1 Complete — What You Now Know
Days 1 to 6: Python basics — variables, data types, input, conditions and loops. Days 7 to 23: Functions, data structures, files, modules, packages and project workflows. Days 24 to 29: Full Object-Oriented Programming. Day 30: A real software system combining everything you've learned.
Key Takeaways
Key Takeaways
- super().__init__() connects child classes to parent classes.
- Inheritance reduces duplicate code by reusing shared functionality.
- Encapsulation protects important data from direct access.
- Polymorphism allows the same method name to produce different behaviours.
- Real software is built by combining small concepts into larger systems.
Continue Learning with Rohi
You've used your 3 free Rohi questions. Create a free account to continue learning.