Project 36: Typing Speed Lab ⌨️¶
Difficulty: 🟡 Intermediate
Run cells top to bottom. Each step builds on the previous one and saves real files under outputs/typing_speed_lab/.
In [1]:
# Install dependencies for this project (safe to re-run)
import sys
!{sys.executable} -m pip install pillow numpy matplotlib wordcloud qrcode[pil] python-barcode fpdf2 jinja2 folium plotly pandas scipy ipywidgets -q
Skipping pip install (already installed)
In [2]:
# Interactive Jupyter setup — run this cell first
%matplotlib inline
from pathlib import Path
from IPython.display import display, Image as IPImage, HTML, Markdown, Audio, IFrame
OUTPUT_DIR = Path("outputs") / "typing_speed_lab"
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
print(f"✅ Outputs folder: {OUTPUT_DIR.resolve()}")
✅ Outputs folder: C:\Users\Hansel Yan\Projects\CodeItAll\outputs\typing_speed_lab
Step 1 — Score attempts¶
In [3]:
# 🎛️ TWEAK THESE (simulated timings so notebooks stay non-interactive)
PROMPTS = [
"python loves clean loops",
"codeitall makes learning playful",
"functions are reusable spells",
]
SECONDS = [4.2, 5.1, 3.8] # pretend you typed each prompt in this many seconds
def wpm(text, seconds):
words = len(text.split())
return words / (seconds / 60)
attempts = []
for text, sec in zip(PROMPTS, SECONDS):
attempts.append({"text": text, "seconds": sec, "wpm": wpm(text, sec), "chars": len(text)})
for a in attempts:
print(f"{a['wpm']:.1f} WPM in {a['seconds']}s — {a['text']}")
57.1 WPM in 4.2s — python loves clean loops 47.1 WPM in 5.1s — codeitall makes learning playful 63.2 WPM in 3.8s — functions are reusable spells
Step 2 — Progress chart¶
In [4]:
import matplotlib.pyplot as plt
xs = [f"Try {i+1}" for i in range(len(attempts))]
ys = [a["wpm"] for a in attempts]
fig, ax = plt.subplots(figsize=(7, 4))
ax.plot(xs, ys, marker="o", color="#111111", linewidth=2)
ax.set_ylabel("WPM")
ax.set_title("Typing Speed Lab — CodeItAll")
ax.set_ylim(0, max(ys) * 1.3)
fig.tight_layout()
out = OUTPUT_DIR / "typing_speed.png"
fig.savefig(out, dpi=140)
plt.show()
(OUTPUT_DIR / "typing_log.txt").write_text(
"\n".join(f"{a['wpm']:.1f}|{a['seconds']}|{a['text']}" for a in attempts),
encoding="utf-8",
)
print(f"Saved {out}")
Saved outputs\typing_speed_lab\typing_speed.png
✅ Project complete¶
Check your output folder: outputs/typing_speed_lab/
Next: Project 37: JSON Adventure Map · Index