Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions student_database.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import os

students = []


def add_student():
num_students = int(input("Enter the number of students: "))

for i in range(num_students):
student = {}
student["name"] = input("Enter the name of the student: ")
student["age"] = input("Enter the age of the student: ")
student["gender"] = input("Enter the gender of the student: ")
students.append(student)



def remove_student():
name = input("Enter the name of the student to remove: ")
for student in students:
Expand All @@ -20,7 +23,8 @@ def remove_student():
break
else:
print("Student not found")



def view_student():
name = input("Enter the name of the student to view: ")
for student in students:
Expand All @@ -31,22 +35,22 @@ def view_student():
break
else:
print("Student not found")



def display_all_students():
for student in students:
print(f"Name: {student['name']}")
print(f"Age: {student['age']}")
print(f"Gender: {student['gender']}")



def update_student():
name = input("Enter the name of the student to update: ")
for student in students:
if student["name"] == name:
student["name"] = input("Enter the name of the student: ")
student["age"] = input("Enter the age of the student: ")
student["gender"] = input("Enter gender of student")




def start():
Expand All @@ -58,9 +62,9 @@ def start():
print("5. Update Student")
print("6. Restart Program")
print("7. Exit Program")

choice = int(input("Enter your choice: "))

if choice == 1:
add_student()
elif choice == 2:
Expand All @@ -74,4 +78,4 @@ def start():
elif choice == 6:
os.system("python3 student_database.py")
elif choice == 7:
os.exit()
os.exit()