0% found this document useful (0 votes)
16 views5 pages

pthon mc code

The document outlines a Student Management System implemented in Python, featuring a Student class and a StudentManagementSystem class. It allows for adding, displaying, updating, and deleting student records through a simple command-line interface. The program runs in a loop until the user chooses to exit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views5 pages

pthon mc code

The document outlines a Student Management System implemented in Python, featuring a Student class and a StudentManagementSystem class. It allows for adding, displaying, updating, and deleting student records through a simple command-line interface. The program runs in a loop until the user chooses to exit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Student Management System

 Code:
class Student:

def _init_(self, student_id, name, age, grade):

self.student_id = student_id

self.name = name

self.age = age

self.grade = grade

class StudentManagementSystem:

def _init_(self):

self.students = {}

def add_student(self):

student_id = input("Enter Student ID: ")

name = input("Enter Student Name: ")

age = input("Enter Student Age: ")

grade = input("Enter Student Grade: ")

self.students[student_id] = Student(student_id, name, age, grade)

print("Student added successfully!\n")

def display_students(self):

if not self.students:

print("No students found!\n")

return

print("Student List:")
for student in self.students.values():

print(f"ID: {student.student_id}, Name: {student.name}, Age: {student.age}, Grade:


{student.grade}")

print()

def update_student(self):

student_id = input("Enter Student ID to update: ")

if student_id in self.students:

name = input("Enter New Name: ")

age = input("Enter New Age: ")

grade = input("Enter New Grade: ")

self.students[student_id] = Student(student_id, name, age, grade)

print("Student updated successfully!\n")

else:

print("Student not found!\n")

def delete_student(self):

student_id = input("Enter Student ID to delete: ")

if student_id in self.students:

del self.students[student_id]

print("Student deleted successfully!\n")

else:

print("Student not found!\n")

def run(self):

while True:

print("1. Add Student")

print("2. Display Students")

print("3. Update Student")


print("4. Delete Student")

print("5. Exit")

choice = input("Enter your choice: ")

if choice == '1':

self.add_student()

elif choice == '2':

self.display_students()

elif choice == '3':

self.update_student()

elif choice == '4':

self.delete_student()

elif choice == '5':

print("Exiting program...")

break

else:

print("Invalid choice! Please try again.\n")

if _name_ == "_main_":

sms = StudentManagementSystem()

sms.run()
 Output:

You might also like