Introduction
Introduction
Introduction
INTRODUCTION
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
1. Student Management:
2. Teacher Management:
4. Fee Management
5. Attendance Management
import csv
class Student:
def __init__(self, name, student_id):
self.name = name
self.student_id = student_id
self.courses = {}
self.attendance = {}
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 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()
self.students[student_id].enroll_course(self.courses[course_code].name)
else:
print("Invalid student ID or course code.")
self.teachers[teacher_id].assign_course(self.courses[course_code].name)
else:
print("Invalid teacher ID or course code.")
self.students[student_id].assign_grade(self.courses[course_code].name,
grade)
else:
print("Invalid student ID or course code.")
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])
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
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")
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,
they teach.
o Course: Represents a course with a name and code.
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.
Initial Menu: