Studypool Professional

students = {}

def add_student():
roll = input(“Enter Roll Number: “)
name = input(“Enter Name: “)
marks = input(“Enter Marks: “)
students[roll] = {“name”: name, “marks”: marks}
print(“Student added successfully!n)

def view_students():
if not students:
print(“No student records found.n)
else:
for roll, details in students.items():
print(f”Roll No: {roll}, Name: {details[‘name’]}, Marks: {details[‘marks’]})
print()

def search_student():
roll = input(“Enter Roll Number to search: “)
if roll in students:
print(“Student Found:”, students[roll])
else:
print(“Student not found.”)
print()

def delete_student():
roll = input(“Enter Roll Number to delete: “)
if roll in students:
del students[roll]
print(“Student deleted successfully!”)
else:
print(“Student not found.”)
print()

while True:
print(“1. Add Student”)
print(“2. View Students”)
print(“3. Search Student”)
print(“4. Delete Student”)
print(“5. Exit”)

choice = input(“Enter your choice: “)

if choice == “1”:
add_student()
elif choice == “2”:
view_students()
elif choice == “3”:
search_student()
elif choice == “4”:
delete_student()
elif choice == “5”:
print(“Exiting program…”)
break
else:
print(“Invalid choice, try again.n)

WRITE MY PAPER

Comments

Leave a Reply