No neural networks. You already know everything this needs: lists, averages, a procedure, and an if. Then the most important demonstration of the unit — 90% accurate, and broken for a quarter of the people.
On this page: AP-TESTABLE sections marked with a BI5 tag · CONTEXT — NOT ON THE AP EXAM anything with this label. Exam-tagged questions never test the context material.
No reading — code. Keep 3.9 (average of a list), 3.12 (procedures with parameters), and 5.7 (filter by category) open.
Impact, in code. You’ll see bias appear in a program you can read line by line.
CONTEXT — NOT ON THE AP EXAM
A classifier sorts items into categories. The simplest one you can build:
Step 2 in a different costume — deciding whether a song is slow or fast by tempo. (AP Pseudocode has no absolute-value procedure, so both versions compare squared distances.)
def closer_to(value, avg_a, avg_b): if (value - avg_a) ** 2 < (value - avg_b) ** 2: return "A" return "B" # slow songs average 75 bpm, fast average 140 print(closer_to(100, 75, 140)) # A (slow)
PROCEDURE closerTo(value, avgA, avgB)
{
IF ((value - avgA) * (value - avgA) <
(value - avgB) * (value - avgB))
{
RETURN("A")
}
RETURN("B")
}
DISPLAY(closerTo(100, 75, 140))CONTEXT — NOT ON THE AP EXAM the idea it demonstrates is AP-TESTABLE
A classifier decides whether a mango is ripe using two measurements: redness and softness. There are two varieties. Variety A turns red when ripe. Variety B stays green when ripe but gets soft. The test set is 75% Variety A and 25% Variety B — like a product used mostly, but not only, by one group. Train it two ways and compare.
Build the one-feature version on the dataset your teacher gives you: a procedure
that averages each category, closer_to, a loop that classifies every test item and counts correct
ones, and accuracy reported overall and for each group. Then swap in the skewed training set
and report what changes.
Five questions. Compute on paper.