About
class Student: def __init__(self, name, roll_number, marks): self.name = name self.roll_number = roll_number self.marks = marks
class StudentManagementSystem: def __init__(self): self.students = []
def add_student(self, student):
self.students.append(student)
def display_all_students(self):
print("Student List:")
for student in self.students:
print(f"Name: {student.name}, Roll Number: {student.roll_number}, Marks: {student.marks}")
def search_student_by_roll_number(self, roll_number):
for student in self.students:
if student.roll_number == roll_number:
print(f"Student found - Name: {student.name}, Roll Number: {student.roll_number}, Marks: {student.marks}")
return
print(f"No student found with Roll Number {roll_number}")
Example Usage:
student_system = StudentManagementSystem()
Adding students
student1 = Student("John Doe", "A101", 85) student2 = Student("Jane Doe", "A102", 92)
student_system.add_student(student1) student_system.add_student(student2)
Display all students
student_system.display_all_students()
Search for a student by roll number
student_system.search_student_by_roll_number("A101")