Overview
Leverage Python's hash maps, unique sets, and immutable tuples for efficient, expressive algorithms.
- dict creation & .get()/.items()
- Set operations: union, intersection
- Tuple unpacking
Short Course
Dicts store key→value pairs for fast lookup. Sets hold unique items. Tuples are immutable ordered sequences.
# Dict - key/value lookup
scores = {"Alice": 95, "Bob": 87}
scores["Carol"] = 91
scores.get("Dave", 0) # -> 0 (safe default)
# Set - unique items
tags = {"py", "web", "py"} # -> {"py", "web"}
# Tuple unpacking
point = (10, 20)
x, y = point # x=10, y=20
Task
Write count_words(sentence) that returns a dict mapping each lowercased word
to its frequency count.
Test Suites
Pending
Stdout