SAT / PSAT
SAT / PSAT Prep
History & Social Science
AP World History AP US History AP European History AP Human Geography AP US Government & Politics AP Psychology AP Macroeconomics AP Microeconomics
English
AP English Language & Composition AP English Literature & Composition
Math & Computer Science
AP Calculus AB/BC AP Precalculus AP Statistics AP Computer Science A AP Computer Science Principles
Sciences
AP Biology AP Chemistry AP Environmental Science AP Physics 1 AP Physics 2
World Languages & Arts
AP Spanish Language AP Art History AP Music Theory Start studying →
Unit 3 · Algorithms & Programming Flashcards Cheat Sheet Essentials Visual Review MC Practice FRQ Practice

AP Computer Science Principles Unit 3 FRQ Practice

Practice a Create-Performance-Task-style written response about a procedure, a list, iteration, and testing. Write your response, then reveal the model answer to see exactly what earns each point.

← Back to Unit 3 hub
Written Response · Unit 3 · Algorithms & Programming

Note: The AP CSP exam is all multiple-choice; extended writing appears in the Create Performance Task. This question gives you practice with that style of written response.

A student builds a to-do list app. The tasks are stored in a list called tasks, and each task has a status of either “done” or “not done”. The program includes a procedure countDone(tasks) that returns how many tasks are marked “done”.

A
Describe the procedure countDone(tasks): identify its parameter, what it returns, and the type(s) of programming construct (selection and/or iteration) it must use.

✓ Model answer

The procedure's parameter is tasks, the list of tasks, and it returns a number — the count of tasks whose status is “done”. To compute this it must use iteration to traverse every task in the list, and selection (a conditional) to check whether each task's status equals “done” and, if so, add 1 to a running count.

Why it scores: Names the parameter and return value, AND correctly states that the procedure needs both iteration (to visit each element) and selection (to test each status). Missing the iteration/selection requirement, or confusing the parameter with the return, would lose credit.
B
Describe, in words or pseudocode, an algorithm the procedure could use to count the “done” tasks. Refer to how it uses the list and a variable.

✓ Model answer

Start by setting a counter variable to 0. Then traverse the list tasks, visiting each task one at a time (for example, with a loop over each index). For each task, use a conditional to check whether its status is “done”; if it is, add 1 to the counter. After the loop has visited every task, return the counter as the total number of completed tasks.

Why it scores: Describes a correct algorithm using a counter variable, iteration over the list, and a conditional, then returns the result. It combines sequencing, selection, and iteration — the foundations of any algorithm.
C
Explain how using a procedure improves the program, and describe how you would test that countDone works correctly.

✓ Model answer

Putting the counting logic in a procedure improves the program through abstraction and reuse: the rest of the program can simply call countDone(tasks) whenever it needs the total, without repeating the code, which makes the program shorter and easier to maintain. To test it, run it with lists whose answers are known — for example, a list where 3 of 5 tasks are “done” should return 3, a list with none done should return 0, and an empty list should return 0. Comparing the results to these expected values (including edge cases) confirms the procedure works.

Why it scores: Explains the benefit of the procedure (abstraction/reuse) AND describes testing with specific inputs and known expected outputs, including edge cases (none done, empty list). A vague "just run it" without concrete test cases would lose credit.

How to write strong AP CSP responses