Learn with Yasir

Share Your Feedback

Student Grade Tracker Solution – Python Mini Project with Code


Explore the complete Python solution for the Student Grade Tracker mini project. Learn how to implement grade entry, calculation, and file-based data management with clean and beginner-friendly code.

Project Details

This beginner-friendly Python project focuses on using lists and tuples to create a simple student grade tracking system. It will help you practice basic operations with these data structures.

Project Description

Create a program that allows users to:

  1. Add student records (name and grades)
  2. Calculate average grades
  3. Find top-performing students
  4. Display all student records

Implementation Steps

Step 1: Initialize Data Structures

# List to store student records (each record is a tuple)
students = []

Step 2: Add Student Function

def add_student():
    name = input("Enter student name: ")
    grades = []
    print("Enter grades (enter 'done' when finished):")
    while True:
        grade = input("Grade: ")
        if grade.lower() == 'done':
            break
        try:
            grades.append(float(grade))
        except ValueError:
            print("Please enter a valid number or 'done'")
    
    # Store as a tuple (name, list of grades)
    students.append((name, grades))
    print(f"Student {name} added successfully!")

Step 3: Calculate Average Grade

def calculate_average(grades):
    return sum(grades) / len(grades) if grades else 0

Step 4: Display All Students

def display_students():
    if not students:
        print("No students in the system.")
        return
    
    print("\nStudent Records:")
    print("-" * 30)
    for student in students:
        name, grades = student
        avg = calculate_average(grades)
        print(f"Name: {name} | Grades: {grades} | Average: {avg:.2f}")
    print("-" * 30)

Step 5: Find Top Performers

def top_performers():
    if not students:
        print("No students in the system.")
        return
    
    # Create a list of tuples (average, name) for sorting
    averages = [(calculate_average(grades), name) for name, grades in students]
    averages.sort(reverse=True)
    
    print("\nTop Performers:")
    print("-" * 30)
    for avg, name in averages[:3]:  # Display top 3
        print(f"{name}: {avg:.2f}")
    print("-" * 30)

Step 6: Main Menu

def main():
    while True:
        print("\nStudent Grade Tracker")
        print("1. Add Student")
        print("2. View All Students")
        print("3. View Top Performers")
        print("4. Exit")
        
        choice = input("Enter your choice (1-4): ")
        
        if choice == '1':
            add_student()
        elif choice == '2':
            display_students()
        elif choice == '3':
            top_performers()
        elif choice == '4':
            print("Exiting program. Goodbye!")
            break
        else:
            print("Invalid choice. Please try again.")

if __name__ == "__main__":
    main()

Explore More Topics

📘 Learn Python

Tutorials, Roadmaps, Bootcamps & Visualization Projects

Python Fundamentals

Flow Control Statements


Python Functions


Fundamentals more ...




🧠 Python Advanced

Object-Oriented Programming in Python (OOP)

More...

🧠 Modules