Python Program: Grade Tracker with Statistics

This program demonstrates key programming concepts such as sequences, selection (if-statements), iteration (loops), and abstraction using functions, parameters, and return values.

Source Code:

# Sequence: A list of student grades
grades = [87, 92, 76, 81, 95, 68, 100, 73, 89]

# Abstraction: A function that calculates average, min, and max grades
def calculate_stats(grade_list):
    if len(grade_list) == 0:
        return (0, 0, 0)
    average = sum(grade_list) / len(grade_list)
    return (average, min(grade_list), max(grade_list))

# Abstraction: A procedure (function) that filters grades above a threshold
def filter_above_threshold(grades, threshold):
    above = []
    for grade in grades:
        if grade > threshold:
            above.append(grade)
    return above

# Selection + Iteration: Categorize grades into letter grades
def categorize_grades(grades):
    letter_grades = []
    for g in grades:
        if g >= 90:
            letter_grades.append("A")
        elif g >= 80:
            letter_grades.append("B")
        elif g >= 70:
            letter_grades.append("C")
        elif g >= 60:
            letter_grades.append("D")
        else:
            letter_grades.append("F")
    return letter_grades

# User interaction loop (iteration)
def main():
    print("Student Grade Tracker")
    print("=====================")
    average, min_grade, max_grade = calculate_stats(grades)
    print(f"Average Grade: {average:.2f}")
    print(f"Minimum Grade: {min_grade}")
    print(f"Maximum Grade: {max_grade}")

    # Let user choose threshold
    threshold = int(input("Enter a threshold to see grades above it: "))
    above_threshold = filter_above_threshold(grades, threshold)
    print(f"Grades above {threshold}: {above_threshold}")

    letters = categorize_grades(grades)
    print(f"Letter grades: {letters}")

# Run the program
main()

✅ Concepts Used
Sequence: grades, letter_grades, and above_threshold lists

Selection: if, elif, else blocks in categorize_grades and filter_above_threshold

Iteration: for loops 
filter_above_threshold

User interaction in main

Abstraction:

calculate_stats() returns multiple values

filter_above_threshold() uses parameters and returns a list

categorize_grades() encapsulates a logic for letter conversion