Learning Python is fun when you build something practical! So far, you’ve covered variables, loops, functions, and data structures like lists, tuples, sets, and dictionaries. Now let’s combine all these concepts into one real-world style project:
👉 A Student Management System.

This project will allow you to:
- Add new students
- Store their marks in different subjects
- Calculate total & average
- Assign grades
- Display all students
- Search for a student by ID
Sounds exciting? Let’s start! 🚀
Project Code: Student Management System
# Student Management System in Python
# Dictionary to store student data
students = {}
# Function to add a new student
def add_student():
student_id = input("Enter Student ID: ")
if student_id in students:
print("Student ID already exists! Use a unique ID.\n")
return
name = input("Enter Student Name: ")
marks = []
# Taking marks input for 3 subjects
for subject in ("Math", "Science", "English"):
score = int(input(f"Enter marks for {subject}: "))
marks.append(score)
# Calculate total, average, and grade
total = sum(marks)
average = total / len(marks)
if average >= 90:
grade = "A"
elif average >= 75:
grade = "B"
elif average >= 50:
grade = "C"
else:
grade = "F"
# Save student record
students[student_id] = {
"name": name,
"marks": tuple(marks), # using tuple for fixed marks
"total": total,
"average": average,
"grade": grade
}
print(f"Student {name} added successfully!\n")
# Function to display all students
def display_students():
if not students:
print("No student records available.\n")
return
for sid, info in students.items():
print(f"ID: {sid} | Name: {info['name']} | Marks: {info['marks']} | "
f"Total: {info['total']} | Avg: {info['average']:.2f} | Grade: {info['grade']}")
print()
# Function to search a student by ID
def search_student():
student_id = input("Enter Student ID to search: ")
if student_id in students:
info = students[student_id]
print(f"--- Student Found ---")
print(f"ID: {student_id}")
print(f"Name: {info['name']}")
print(f"Marks: {info['marks']}")
print(f"Total: {info['total']}")
print(f"Average: {info['average']:.2f}")
print(f"Grade: {info['grade']}\n")
else:
print("Student not found.\n")
# Main menu
while True:
print("=== Student Management System ===")
print("1. Add Student")
print("2. Display All Students")
print("3. Search Student by ID")
print("4. Exit")
choice = input("Choose an option (1-4): ")
if choice == "1":
add_student()
elif choice == "2":
display_students()
elif choice == "3":
search_student()
elif choice == "4":
print("Exiting... Goodbye!")
break
else:
print("Invalid choice. Please try again.\n")
Sample Output
=== Student Management System ===
1. Add Student
2. Display All Students
3. Search Student by ID
4. Exit
Choose an option (1-4): 1
Enter Student ID: S101
Enter Student Name: Ramesh
Enter marks for Math: 95
Enter marks for Science: 89
Enter marks for English: 92
Student Ramesh added successfully!
Choose an option (1-4): 2
ID: S101 | Name: Ramesh | Marks: (95, 89, 92) | Total: 276 | Avg: 92.00 | Grade: A
Also Read: Simple ATM Project in Python
Code Explanation
Let’s break down the project step by step so you fully understand how each part works.
1. Storing Student Data
We use a dictionary to store all students. Each student will have a unique Student ID as the key, and their details (name, marks, total, average, grade) will be stored as values.
students = {}
For example, after adding one student, the dictionary might look like this:
{
"S101": {
"name": "Ramesh",
"marks": (95, 89, 92),
"total": 276,
"average": 92.0,
"grade": "A"
}
}
2. Adding a New Student
We created a function add_student()
to handle new entries.
def add_student():
student_id = input("Enter Student ID: ")
if student_id in students:
print("Student ID already exists! Use a unique ID.\n")
return
- First, we ask the user for a Student ID.
- If the ID already exists, we stop to avoid duplicates (just like a real database would).
Then we take the name and marks:
name = input("Enter Student Name: ")
marks = []
for subject in ("Math", "Science", "English"):
score = int(input(f"Enter marks for {subject}: "))
marks.append(score)
- We loop over three subjects and collect marks.
- Marks are added into a list.
Next, calculate total, average, and grade:
total = sum(marks)
average = total / len(marks)
if average >= 90:
grade = "A"
elif average >= 75:
grade = "B"
elif average >= 50:
grade = "C"
else:
grade = "F"
Finally, save all data into the dictionary:
students[student_id] = {
"name": name,
"marks": tuple(marks), # using tuple (immutable marks)
"total": total,
"average": average,
"grade": grade
}
3. Displaying All Students
This function shows all student details in a clean format.
def display_students():
if not students:
print("No student records available.\n")
return
for sid, info in students.items():
print(f"ID: {sid} | Name: {info['name']} | Marks: {info['marks']} | "
f"Total: {info['total']} | Avg: {info['average']:.2f} | Grade: {info['grade']}")
print() # just for new line
- If dictionary is empty, it prints “No student records”.
- Otherwise, it loops over each student and prints details.
:.2f
ensures average is displayed with two decimal places (e.g., 92.33).
4. Searching for a Student
We allow searching by Student ID.
def search_student():
student_id = input("Enter Student ID to search: ")
if student_id in students:
info = students[student_id]
print(f"--- Student Found ---")
print(f"ID: {student_id}")
print(f"Name: {info['name']}")
print(f"Marks: {info['marks']}")
print(f"Total: {info['total']}")
print(f"Average: {info['average']:.2f}")
print(f"Grade: {info['grade']}\n")
else:
print("Student not found.\n")
- If the ID exists, details are displayed.
- If not, we show “Student not found”.
5. Menu System
The heart of the project is a loop that keeps running until the user exits.
while True:
print("=== Student Management System ===")
print("1. Add Student")
print("2. Display All Students")
print("3. Search Student by ID")
print("4. Exit")
choice = input("Choose an option (1-4): ")
Depending on the user’s choice, the right function runs:
if choice == "1":
add_student()
elif choice == "2":
display_students()
elif choice == "3":
search_student()
elif choice == "4":
print("Exiting... Goodbye!")
break
else:
print("Invalid choice. Please try again.\n")
- The loop keeps showing the menu until user selects
4
to exit. - Invalid choices are handled gracefully.
Why This Project is Useful?
This project helps you practice:
✅ Variables & Data Types
✅ Input & Output
✅ Operators (sum, average, comparison)
✅ Conditional Statements (grading system)
✅ Loops (menu, marks entry)
✅ Functions (organizing code)
✅ Lists, Tuples, Dictionaries (storing data)
✅ Sets (ensuring unique IDs if extended)
Final Thoughts
This Student Management System may look simple, but it’s powerful because it combines almost every basic Python concept you’ve learned so far. You can extend it by:
- Adding “delete student” feature
- Saving data to a file (File Handling – upcoming topic!)
- Using sets to check for unique IDs
- Sorting students by grades
Keep practicing, and soon you’ll be ready for advanced Python projects like web automation, APIs, and GUIs.
What’s Next?
In the next post, we’ll learn about the String Manipulation in Python