Unit 3 · Programming 2 · Lesson 3.14

Procedures + Lists: the Create PT Pattern

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.

Big Idea 3 — Algorithms & ProgrammingThe Create PT shape

Before this lesson

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.

1

Where We Are

People→ Bits→ Programs→ Internet→ Security→ Big Data→ Impact

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.

2

The Hook

Read this sentence slowly: “A student-developed procedure with a parameter that contains selection and iteration, and is called from the program.”

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.

3

The Idea

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:

Python — the pattern

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

The four requirements, labeled

# 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.

Say the sentence about your own code. On the PT you must point to your procedure and say what it does: “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.
Why a list parameter matters. Passing the list in (not global variables) is what makes the procedure reusable: the same count_above works on quiz scores, test scores, or temperatures. Reusability across different data is exactly the “managing complexity” the PT rewards.
4

Try It — Call the PT Procedure

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.

count_above([ ], )
press Call to run the procedure
5

Vocabulary

list parameter Programs
A parameter that receives a whole list, so one procedure can work on any list of data passed to it.
the Create PT code requirement Programs
A student-developed procedure with a parameter, containing selection and iteration, and called from the program — the exact shape on this page.
6

Check

Five questions. Find each required ingredient in the code, and trace the procedure’s return value. Then pick your answer.

0 of 5 answered
7

Impact Check

This shape is most useful programs, not just the PT

“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.

8

Connections

Assembles the whole unit — lists (3.6), traversal (3.8), selection (2.12), and procedures with return (3.12–3.13), in one pattern.
Next in 3.15 — you rebuild the gradebook out of procedures shaped exactly like this.
Returns in Week 5 — the Practice PT (3.21–3.25) is you writing this pattern for real and explaining it in writing.
Returns on the exam — “which requirement does this code satisfy?” and “what does this procedure return?” are both here.
← 3.13 return vs print