PYTHON PROJECT 12

Student Management

Learn how to create a Student Management System using Python lists, dictionaries, functions, searching, updating and deleting records.

1. Project Introduction

A Student Management System is used to store and manage student information.

In this project, we will manage student names, courses, ages, marks and other basic information.

This is an educational project. A production student management system would normally use a database, authentication and proper access control.

2. Creating Student Data

A dictionary can represent one student.

student = {
    "id": 1,
    "name": "Rahul",
    "age": 20,
    "course": "Python",
    "marks": 85
}

3. Creating the Student List

Multiple students can be stored inside a list.

students = []

4. Adding a Student

student = {
    "id": 1,
    "name": "Rahul",
    "age": 20,
    "course": "Python",
    "marks": 85
}

students.append(student)

5. Creating an Add Student Function

def add_student(
    student_id,
    name,
    age,
    course,
    marks
):

    student = {
        "id": student_id,
        "name": name,
        "age": age,
        "course": course,
        "marks": marks
    }

    students.append(student)

6. Viewing Students

A for loop can display every student.

for student in students:

    print("ID:", student["id"])
    print("Name:", student["name"])
    print("Age:", student["age"])
    print("Course:", student["course"])
    print("Marks:", student["marks"])
    print()

7. Searching for a Student

A unique student ID can be used to find a student.

search_id = int(
    input("Enter student ID: ")
)

for student in students:

    if student["id"] == search_id:

        print(student)

8. Searching by Name

We can also search students using their names.

search_name = input(
    "Enter student name: "
).lower()

for student in students:

    if search_name in student["name"].lower():

        print(student)

9. Updating Student Information

Dictionary values can be changed using their keys.

student["course"] = "Web Development"

student["marks"] = 90

10. Deleting a Student

Once the student is found, it can be removed from the list.

for student in students:

    if student["id"] == student_id:

        students.remove(student)

        break

11. Calculating Grade

Student marks can be converted into a grade using conditions.

marks = student["marks"]

if marks >= 90:

    grade = "A+"

elif marks >= 80:

    grade = "A"

elif marks >= 70:

    grade = "B"

elif marks >= 60:

    grade = "C"

elif marks >= 50:

    grade = "D"

else:

    grade = "F"

12. Validating Marks

Marks should normally be between 0 and 100.

if marks < 0 or marks > 100:

    print(
        "Marks must be between 0 and 100."
    )

13. Calculating Average Marks

We can calculate the average marks of all students.

total = 0

for student in students:

    total += student["marks"]

if students:

    average = (
        total / len(students)
    )

    print("Average:", average)

14. Creating Separate Functions

A clean Student Management System can use separate functions for different operations.

15. Creating a Menu

while True:

    print("1. Add Student")
    print("2. View Students")
    print("3. Search Student")
    print("4. Update Student")
    print("5. Delete Student")
    print("6. Exit")

    choice = input(
        "Enter choice: "
    )

16. Using if / elif

if choice == "1":

    add_student()

elif choice == "2":

    view_students()

elif choice == "3":

    search_student()

elif choice == "4":

    update_student()

elif choice == "5":

    delete_student()

elif choice == "6":

    break

17. Input Validation

if not name:

    print("Name is required.")

elif age <= 0:

    print("Invalid age.")

elif marks < 0 or marks > 100:

    print("Invalid marks.")

else:

    add_student(
        student_id,
        name,
        age,
        course,
        marks
    )

18. Complete Project Flow

01 Create Student List
02 Add Student
03 View Students
04 Search Student
05 Update Student
06 Delete Student
07 Calculate Grade
08 Validate Data

19. Concepts You Practiced

20. Run Complete Project 🚀

You have learned the core concepts behind a Student Management System. Now open the complete interactive project.

Run Complete Project