Introduction

Download as pdf or txt
Download as pdf or txt
You are on page 1of 32

INTRODUCTION

INTRODUCTION

The School Management System is a Python-based


project designed to manage various operations in a
school, such as student enrollment, teacher records,
and class assignments. The system automates the
task of managing data related to students, teachers,
and classes, allowing for easier management,
retrieval, and modification of information. This
project demonstrates the practical implementation
of Python programming concepts like object-
oriented programming (OOP), file handling, and user
input handling.
OBJECTIVES
OBJECTIVES

 To create a system that manages student


and teacher data.
 To automate tasks like course assignments,
fee payments, and attendance tracking.
 To implement a Python-based solution using
file handling to persist data.
SYSTEM
REQUIREMENTS
SYSTEM REQUIREMENTS

Hardware Requirements:
 Processor: Intel Core i3 or higher
 RAM: 4 GB or more
 Storage: At least 100 MB of free space
Software Requirements:
 Operating System: Windows, macOS, or Linux
 Programming Language: Python 3.8 or above
 Text Editor/IDE: PyCharm, VS Code, or any
Python-supported editor
 Optional: SQLite or CSV for data storage
PROBLEM STATEMENT
PROBLEM STATEMENT

In schools, managing records of students,


teachers, and classes is essential. Traditionally,
this task is handled manually using paper-based
systems or spreadsheets, which can be prone to
errors, mismanagement, and loss of data. This
project aims to solve these issues by building a
School Management System that automates
tasks such as adding, viewing, updating, and
deleting records. The system aims to enhance
productivity and reduce the chances of manual
errors.
MAIN STRUCTURE OF
THE PROGRAM
MAIN STRUCTURE OF THE
PROGRAM

1. Student Management:

2. Teacher Management:

3. Class and Course Management

4. Fee Management
5. Attendance Management

6. File Handling (CSV) for data persistence


PYTHON PROGRAM
PYTHON PROGRAM: SCHOOL
MANAGEMENT SYSTEM
# School Management System

import csv

class Student:
def __init__(self, name, student_id):
self.name = name
self.student_id = student_id
self.courses = {}
self.attendance = {}

def enroll_course(self, course):


self.courses[course] = None # No grade yet
self.attendance[course] = 0 # No attendance yet
print(f"{self.name} has enrolled in {course}")

def record_attendance(self, course, present=True):


if course in self.attendance:
self.attendance[course] += 1 if present else 0
print(f"Attendance recorded for {self.name} in {course}: {'Present'
if present else 'Absent'}")
else:
print(f"{self.name} is not enrolled in {course}")
def assign_grade(self, course, grade):
if course in self.courses:
self.courses[course] = grade
print(f"{self.name} has received {grade} in {course}")
else:
print(f"{self.name} is not enrolled in {course}")

def generate_report(self):
print(f"\n--- Report for {self.name} ---")
for course, grade in self.courses.items():
attendance_count = self.attendance[course]
print(f"Course: {course}, Grade: {grade if grade else 'Not graded'},
Attendance: {attendance_count} days")

class Teacher:
def __init__(self, name, teacher_id):
self.name = name
self.teacher_id = teacher_id
self.courses = []

def assign_course(self, course):


self.courses.append(course)
print(f"{self.name} is assigned to teach {course}")

def display_courses(self):
print(f"{self.name} is teaching: {', '.join(self.courses)}")
class Course:
def __init__(self, name, course_code):
self.name = name
self.course_code = course_code

def display(self):
print(f"Course: {self.name}, Code: {self.course_code}")

class SchoolManagementSystem:
def __init__(self):
self.students = {}
self.teachers = {}
self.courses = {}
self.load_data()

def add_student(self, name, student_id):


if student_id not in self.students:
self.students[student_id] = Student(name, student_id)
print(f"Student {name} added with ID {student_id}.")
else:
print(f"Student ID {student_id} already exists.")

def add_teacher(self, name, teacher_id):


if teacher_id not in self.teachers:
self.teachers[teacher_id] = Teacher(name, teacher_id)
print(f"Teacher {name} added with ID {teacher_id}.")
else:
print(f"Teacher ID {teacher_id} already exists.")

def add_course(self, name, course_code):


if course_code not in self.courses:
self.courses[course_code] = Course(name, course_code)
print(f"Course {name} added with code {course_code}.")
else:
print(f"Course code {course_code} already exists.")

def enroll_student_in_course(self, student_id, course_code):


if student_id in self.students and course_code in self.courses:

self.students[student_id].enroll_course(self.courses[course_code].name)
else:
print("Invalid student ID or course code.")

def assign_teacher_to_course(self, teacher_id, course_code):


if teacher_id in self.teachers and course_code in self.courses:

self.teachers[teacher_id].assign_course(self.courses[course_code].name)
else:
print("Invalid teacher ID or course code.")

def record_student_attendance(self, student_id, course_code,


present=True):
if student_id in self.students and course_code in self.courses:
self.students[student_id].record_attendance(self.courses[course_code].n
ame, present)
else:
print("Invalid student ID or course code.")

def assign_student_grade(self, student_id, course_code, grade):


if student_id in self.students and course_code in self.courses:

self.students[student_id].assign_grade(self.courses[course_code].name,
grade)
else:
print("Invalid student ID or course code.")

def generate_student_report(self, student_id):


if student_id in self.students:
self.students[student_id].generate_report()
else:
print("Invalid student ID.")

def save_data(self):
# Save students data
with open('students.csv', mode='w', newline='') as file:
writer = csv.writer(file)
writer.writerow(['student_id', 'name', 'courses', 'attendance'])
for student_id, student in self.students.items():
courses_str = ';'.join([f"{course}:{grade}" for course, grade in
student.courses.items()])
attendance_str = ';'.join([f"{course}:{count}" for course, count in
student.attendance.items()])
writer.writerow([student_id, student.name, courses_str,
attendance_str])

# Save teachers data


with open('teachers.csv', mode='w', newline='') as file:
writer = csv.writer(file)
writer.writerow(['teacher_id', 'name', 'courses'])
for teacher_id, teacher in self.teachers.items():
courses_str = ';'.join(teacher.courses)
writer.writerow([teacher_id, teacher.name, courses_str])

# Save courses data


with open('courses.csv', mode='w', newline='') as file:
writer = csv.writer(file)
writer.writerow(['course_code', 'name'])
for course_code, course in self.courses.items():
writer.writerow([course_code, course.name])

def load_data(self):
# Load students data
try:
with open('students.csv', mode='r') as file:
reader = csv.DictReader(file)
for row in reader:
student = Student(row['name'], row['student_id'])
courses = row['courses'].split(';')
attendance = row['attendance'].split(';')
for course in courses:
if ':' in course:
course_name, grade = course.split(':')
student.courses[course_name] = grade
for att in attendance:
if ':' in att:
course_name, count = att.split(':')
student.attendance[course_name] = int(count)
self.students[row['student_id']] = student
except FileNotFoundError:
pass

# Load teachers data


try:
with open('teachers.csv', mode='r') as file:
reader = csv.DictReader(file)
for row in reader:
teacher = Teacher(row['name'], row['teacher_id'])
teacher.courses = row['courses'].split(';')
self.teachers[row['teacher_id']] = teacher
except FileNotFoundError:
pass

# Load courses data


try:
with open('courses.csv', mode='r') as file:
reader = csv.DictReader(file)
for row in reader:
course = Course(row['name'], row['course_code'])
self.courses[row['course_code']] = course
except FileNotFoundError:
pass

def main():
system = SchoolManagementSystem()

while True:
print("\n--- School Management System ---")
print("1. Add Student")
print("2. Add Teacher")
print("3. Add Course")
print("4. Enroll Student in Course")
print("5. Assign Teacher to Course")
print("6. Record Student Attendance")
print("7. Assign Student Grade")
print("8. Generate Student Report")
print("9. Exit")

choice = input("Enter your choice: ")

if choice == '1':
name = input("Enter student name: ")
student_id = input("Enter student ID: ")
system.add_student(name, student_id)
elif choice == '2':
name = input("Enter teacher name: ")
teacher_id = input("Enter teacher ID: ")
system.add_teacher(name, teacher_id)
elif choice == '3':
name = input("Enter course name: ")
course_code = input("Enter course code: ")
system.add_course(name, course_code)
elif choice == '4':
student_id = input("Enter student ID: ")
course_code = input("Enter course code: ")
system.enroll_student_in_course(student_id, course_code)
elif choice == '5':
teacher_id = input("Enter teacher ID: ")
course_code = input("Enter course code: ")
system.assign_teacher_to_course(teacher_id, course_code)
elif choice == '6':
student_id = input("Enter student ID: ")
course_code = input("Enter course code: ")
attendance = input("Is the student present? (yes/no): ").lower() ==
'yes'
system.record_student_attendance(student_id, course_code,
attendance)
elif choice == '7':
student_id = input("Enter student ID: ")
course_code = input("Enter course code: ")
grade = input("Enter grade: ")
system.assign_student_grade(student_id, course_code, grade)
elif choice == '8':
student_id = input("Enter student ID: ")
system.generate_student_report(student_id)
elif choice == '9':
print("Saving data and exiting the School Management System.")
system.save_data()
break
else:
print("Invalid choice. Please try again.")

if __name__ == "__main__":
main()
Explanation of the
Code
Explanation of the Code:
1. Classes:
o Student: Manages student details, course enrollment,

attendance, and grades.


o Teacher: Manages teacher details and the courses

they teach.
o Course: Represents a course with a name and code.

o SchoolManagementSystem: Central class that

manages students, teachers, and courses, and


provides methods for various actions.
2. Menu System:
o The main() function displays a text-based menu to

interact with the user.


o Users can add students, teachers, and courses, enroll

students in courses, assign grades, record attendance,


and generate reports.
3. User Interaction:
o The program accepts input from users to perform

various actions, making it user-friendly and


interactive.

Features Implemented:
 Student Management: Adding students, enrolling in
courses, and managing grades.
 Teacher Management: Adding teachers and assigning
courses.
 Course Management: Adding courses.
 Attendance Management: Recording attendance for
students.
 Grade Management: Assigning grades to students.
 Reports Generation: Generating reports for students.

How to Run the Program:

1. Copy the code into a Python (.py) file (e.g.,


school_management_system.py).
2. Run the program using a Python interpreter (e.g., python
school_management_system.py).
3. Follow the on-screen prompts to interact with the system.

This program is designed to be modular and can easily be


extended with additional features or improved error handling
as needed.
OUTPUTS
SAMPLE OUTPUT FOR THE SCHOOL MANAGEMENT
SYSTEM

Initial Menu:

Example Run of the Program:


Step 1: Adding a Student

Step 2: Adding a Teacher


Step 3: Adding a Course

Step 4: Enroll a Student in a Course

Step 5: Assign a Teacher to a Course

Step 6: Record Student Attendance


Step 7: Assign a grade to a Student

Step 8: Generate a Report for a Student

Step 9: Exit the system


BREAKDOWN OF THE
OUTPUT
Breakdown of the output
1. Adding Students and Teachers: The system confirms the
successful addition of a student and a teacher.
2. Adding Courses: The course "Mathematics" with the code
"MATH101" is added to the system.
3. Enrollment: The student "Alice" is enrolled in the
"Mathematics" course.
4. Assigning Teachers: The teacher "Mr. Smith" is assigned to
teach "Mathematics".
5. Recording Attendance: Alice's attendance is recorded for
the course "Mathematics", with the system confirming
that she was present.
6. Assigning Grades: Alice receives an "A" grade in the course
"Mathematics".
7. Report Generation: A report for Alice is generated,
showing her grade and attendance in "Mathematics".
8. Exit: The system exits gracefully after user confirmation.
CONCLUSION
Conclusion
This output demonstrates a successful workflow of
the School Management System. You can extend this
by adding more students, teachers, courses, and
generating multiple reports. The system handles
simple actions like adding, enrolling, and generating
reports interactively through the menu.

You might also like