You've covered OOP, file I/O, APIs, list comprehensions, decorators, regex, CLIs, packages, and testing. Now bring it all together: build a complete, tested Python command-line tool that solves a real problem.
Key Concepts
Project Ideas
Weather dashboard: fetch real weather, display nicely. Student gradebook: JSON storage, CRUD operations, statistics. News headline fetcher: API + filtering. Text analyzer: regex + statistics on a text file.
1. Define the problem clearly 2. Design the class structure 3. Write tests first (TDD) 4. Implement the code 5. Refactor for clarity 6. Document with docstrings
Sharing Your Work
Push to GitHub. Add a README with: what the tool does, how to install (requirements.txt), how to use it (examples), and your name. This is your portfolio piece — employers and colleges look at GitHub.
# CAPSTONE: Mini Gradebook Tool
# Combines: OOP, file I/O (JSON), error handling, list comprehensions, CLI
import json, io
from statistics import mean, median, stdev
class Gradebook:
def __init__(self):
self.students = {} # name -> list of scores
def add_score(self, name, score):
if not 0 <= score <= 100:
raise ValueError(f"Score must be 0-100 (got {score})")
self.students.setdefault(name, []).append(score)
def average(self, name):
scores = self.students.get(name, [])
return mean(scores) if scores else None
def class_stats(self):
all_scores = [s for scores in self.students.values() for s in scores]
if len(all_scores) < 2: return None
return {"mean": mean(all_scores), "median": median(all_scores),
"std": stdev(all_scores), "min": min(all_scores), "max": max(all_scores)}
def honor_roll(self, threshold=90):
return [n for n, s in self.students.items() if self.average(n) >= threshold]
def to_json(self):
return json.dumps(self.students, indent=2)
# Demo
gb = Gradebook()
for name, scores in [("Alex",[92,88,95]),("Brooke",[78,85,82]),
("Carlos",[95,98,91]),("Dana",[65,72,70]),("Eli",[88,90,85])]:
for s in scores: gb.add_score(name, s)
print("=== Gradebook Report ===")
for name in sorted(gb.students):
avg = gb.average(name)
grade = "A" if avg>=90 else "B" if avg>=80 else "C" if avg>=70 else "D"
print(f" {name:<12} avg={avg:5.1f} grade={grade}")
stats = gb.class_stats()
print(f"\nClass Stats: mean={stats['mean']:.1f} median={stats['median']:.1f} std={stats['std']:.1f}")
print(f"Honor Roll: {gb.honor_roll()}")
print(f"\nJSON export preview:\n{gb.to_json()[:120]}...")
✅ Check Your Understanding
1. What is the recommended first step of a development project?