Week 1 • Friday

Block 10: Mini-Project: Personal Stats Summary

Integrate variables, lists, loops, and functions into one script.

Concepts

Code Examples

Full project structure

def load_data():
    return [(8000,2,2.5), (7200,1.5,2), ...]

def compute_stats(data):
    ...

def print_report(stats):
    ...

if __name__ == '__main__':
    data = load_data()
    stats = compute_stats(data)
    print_report(stats)

f-string formatting

name = 'Alex'
score = 87.5
print(f'{name} scored {score:.1f}%')
print(f'Progress: {5/10*100:.0f}%')

Exercise

Build a script: input 7 days of (steps, study_hours, water_liters), compute totals and averages, print a clear formatted report. Add a function highlight(value, goal) that prints 'Great!' or 'Try harder!' depending on whether the goal was met.

Solution
def highlight(value, goal):
    return 'Great!' if value >= goal else 'Try harder!'

data = [
    (8000, 2, 2.5), (7200, 1.5, 2), (9000, 3, 3),
    (6500, 2, 2), (8500, 2.5, 2.5), (7000, 1, 2),
    (9500, 3, 3)
]

steps = [d[0] for d in data]
study = [d[1] for d in data]
water = [d[2] for d in data]

total_steps = sum(steps)
avg_study = sum(study) / len(study)
avg_water = sum(water) / len(water)

print('=== Weekly Personal Stats ===')
print(f'Total steps: {total_steps}')
print(f'Avg study hours: {avg_study:.1f}')
print(f'Avg water (L): {avg_water:.1f}')
print(f'Steps goal: {highlight(total_steps, 50000)}')
print(f'Study goal: {highlight(avg_study, 2)}')

Practice Problems

Problem 1: Extend the script to accept user input for each day instead of hardcoded data.

Hint: Use input() in a loop

Problem 2: Add a function that returns a letter grade (A-F) based on average study hours.

Hint: Reuse conditionals from Block 3

Application

Real projects combine many small pieces. This mini-project mirrors the structure of larger data pipelines.

Case Study

A fitness app aggregates daily metrics (steps, sleep, calories) into weekly reports. The same pattern: collect → compute → format → display.

Project

Build a complete personal dashboard script that tracks 3 metrics over 7 days and produces a formatted report with goal highlights.

Homework

Reflection: list 3 things you learned, 2 things that confused you, 1 thing you want to explore further.