Prompt Detail:
Sure, here's an example of object-oriented Python code that implements a student database system:
pythonclass Student:
def __init__(self, name, age, gender, grade, address, parent_name, parent_phone):
self.name = name
self.age = age
self.gender = gender
self.grade = grade
self.address = address
self.parent_name = parent_name
self.parent_phone = parent_phone
self.attendance = {}
self.grades = {}
self.disciplinary_records = []
def add_attendance(self, date, status):
self.attendance[date] = status
def add_grade(self, subject, score):
self.grades[subject] = score
def add_disciplinary_record(self, record):
self.disciplinary_records.append(record)
class StudentDatabase:
def __init__(self):
self.students = []
def add_student(self, student):
self.students.append(student)
def get_student_by_name(self, name):
for student in self.students:
if student.name == name:
return student
return None
def get_student_by_grade(self, grade):
grade_students = []
for student in self.students:
if student.grade == grade:
grade_students.append(student)
return grade_students
Add a comment