Repository navigation
Expand file tree
/
Copy pathTask_9_Student_Record_System.py
More file actions
98 lines (71 loc) · 2.51 KB
/
Copy pathTask_9_Student_Record_System.py
File metadata and controls
98 lines (71 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Task 9: Student Record Management System
# This program allows the user to add, display, search,
# and delete student records.
student_records = []
def add_student():
name = input("Enter student name: ")
age = int(input("Enter student age: "))
branch = input("Enter student branch: ")
marks = float(input("Enter student marks: "))
student = {
"Name": name,
"Age": age,
"Branch": branch,
"Marks": marks
}
student_records.append(student)
print("Student record added successfully.")
def display_students():
if len(student_records) == 0:
print("No student records available.")
return
print("\n----- Student Records -----")
for student in student_records:
print("Name :", student["Name"])
print("Age :", student["Age"])
print("Branch:", student["Branch"])
print("Marks :", student["Marks"])
print("--------------------------")
def search_student():
search_name = input("Enter student name to search: ")
found = False
for student in student_records:
if student["Name"].lower() == search_name.lower():
print("\nStudent found!")
print("Name :", student["Name"])
print("Age :", student["Age"])
print("Branch:", student["Branch"])
print("Marks :", student["Marks"])
found = True
break
if not found:
print("Student record not found.")
def delete_student():
delete_name = input("Enter student name to delete: ")
for student in student_records:
if student["Name"].lower() == delete_name.lower():
student_records.remove(student)
print("Student record deleted successfully.")
return
print("Student record not found.")
while True:
print("\n===== Student Record Management System =====")
print("1. Add Student")
print("2. Display All 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":
display_students()
elif choice == "3":
search_student()
elif choice == "4":
delete_student()
elif choice == "5":
print("Thank you for using the Student Record Management System.")
break
else:
print("Invalid choice. Please try again.")