This is the one. A procedure that takes a list as a parameter and traverses it — with selection and iteration inside — called from your main program. That single sentence is the code requirement of the Create Performance Task.
No new reading — this is assembly day. You already have every piece: lists (3.6), traversal (3.8), selection (2.12–2.13), and procedures with parameters and return (3.12–3.13). Today they click into one shape.
Still in Programs, at the summit of the unit. Every skill so far was a piece of this one pattern. Learn to recognize and write it now, and the Create PT’s scariest requirement becomes something you’ve done a dozen times.
That is, almost word for word, the code requirement of
the AP Create Performance Task — the project worth a big chunk of your exam score. It sounds
intimidating. It is also exactly count_above(scores, cutoff), which you’re about
to write. You already know every word in that sentence.
Wrap a list-traversal in a procedure that takes the list as a parameter, put an
if inside the loop, and return the result. That’s the whole pattern
— and it has all four required ingredients at once:
def count_above(scores, cutoff): count = 0 for s in scores: # iteration if s > cutoff: # selection count = count + 1 return count grades = [85, 90, 78, 60] print(count_above(grades, 80)) # 2
# a PROCEDURE you defined, # with PARAMETERS (scores, cutoff) # — and one is a LIST # ITERATION over the list # SELECTION inside the loop # accumulator update # RETURN the result # the list argument # CALLED from the program
Hover or tap a line to light its twin. Count the requirements on the right: a
student-developed procedure, a parameter (a list), iteration, selection, and a call. All five, in
nine lines. count_above(grades, 80) returns 2 — the scores above 80 are 85 and 90.
count_above takes a list of scores and a cutoff, uses
iteration to look at each score and selection to test it against the cutoff, and returns how many
are above it.” Practicing that sentence now is practicing the written response.
count_above works on quiz scores, test scores,
or temperatures. Reusability across different data is exactly the “managing complexity”
the PT rewards.
Here is count_above(scores, cutoff). Change the list and the cutoff and call it —
watch the same procedure work on any data you give it.
Five questions. Find each required ingredient in the code, and trace the procedure’s return value. Then pick your answer.
“Take a collection, look at each item, keep or count the ones
that match, hand back the result” is the skeleton of search, filtering, analytics, and
recommendations. count_above becomes “how many transactions over $10,000,”
“which users were active this week,” “how many pixels are too dark.” Same
shape, world-changing scale.
The College Board built the Create PT around this pattern precisely because it’s the irreducible core of programming: a named, reusable operation over a collection. Nail it here and you’re not just passing a task — you’re holding the shape that most software is made of.