Pseudocode Tracer: Assignment Is a Copy
The AP CSP exam asks students to trace code written in the exam reference sheet's own notation, and the very first rule they need is what the arrow does. The CED's own example (AAP-1.B.3) is a ← 1, b ← a, a ← 2, DISPLAY(b): it still displays 1, and many students say 2. In this lesson students trace short programs in a step-by-step tracer that runs the reference sheet's notation exactly. At the lines marked with a question mark, the tracer stops and asks what the variable will hold or what will be displayed, and checks the answer before it runs the line. Students find that assignment copies a value instead of linking two names, that a variable holds only its most recent value, why a swap needs a third variable, and how MOD and division work on the exam. They finish with exam-style questions whose wrong choices come from running each common mistake.
At a glance
Essential question
When the reference sheet's arrow runs, what exactly does the variable on its left hold afterward?
Objectives
Students will be able to:
- determine the value of a variable after a sequence of assignments (AAP-1.B)
- explain why assignment copies a value instead of linking two variables
- trace a swap and explain why it needs a third variable
- evaluate expressions with +, -, *, / and MOD as the reference sheet defines them (AAP-2.C)
Vocabulary
variable, assignment, expression, MOD, trace, trace table, exam reference sheet
Standards
AAP-1.B, AAP-2.C, 2-AP-11
Time and materials
45 minutes, grades 9-12.
- One computer or Chromebook per student or pair
- A projector
- The worksheet and exit ticket, one copy each per student
- The AP CSP Exam Reference Sheet (in the CED's appendix), one copy per student or pair
- The rubric, one copy per student if you grade the project
Prep
Make copies of the worksheet, the exit ticket and the exam reference sheet. Before class, open mytekdev.com/try/pseudocode?lesson=assignment-is-a-copy&ref=tpt-pseudo-1 once on a student computer to check that your school's filter allows it, and run the walkthrough in Before you teach once (about ten minutes). No account is needed.
Assessment
- Formative: the predictions the tracer checks, the questions under What to look for, and the exit ticket (answer key included).
- Summative: the worksheet's trace table and its two written answers, scored with the rubric out of 12.
Technology and privacy
Runs in any browser, Chromebooks included, with nothing to install. The tracer runs the exam reference sheet's text notation, with lists that start at 1 and assignment that copies, as the sheet defines them; where the sheet leaves a choice open, the tracer says so on its Outside the sheet page. Students need no account and no email: the link works signed out, and nothing they make is stored on our server unless they choose to save it to an account. If your school blocks new sites, ask IT to allow mytekdev.com.
mytekdev.com/try/pseudocode?lesson=assignment-is-a-copy&ref=tpt-pseudo-1mytekdev.com/tools/ap-csp-pseudocode-tracer/lessons/assignment-is-a-copy/startEach student gets their own copy, and the same link reopens it next time. How to set up a classBefore you teach: do it once yourself
Step through the starter, the swap and one exam question yourself once before class, about ten minutes.
- Open the lesson. Go to mytekdev.com/try/pseudocode?lesson=assignment-is-a-copy&ref=tpt-pseudo-1. The starter program is on the left, with a ? in front of lines 3, 5 and 8.
- Step and predict. Press Step until it stops at line 3 and asks Line 3 is next. What will score be after it runs? Type 10 and press Check: Not yet. It was 15. Step on to line 5 and answer 10: Right.
- Finish the run. Keep stepping (line 8 asks about lives: 4). The program displays 15, 10 and 4.
- Swap. Choose Example, Swapping two values, and step through. The first try displays 8 8, the second 8 3. Open the Trace table tab to see a row for each change.
- Exam question. Choose Example, Order of operations. Open Teach, then Exam question, and pick a choice. The right one is 18 28 3 2.5.
The tracer stops before a ? line and checks the prediction.
Exam question: each wrong choice is what a real mistake displays.
Background in plain words
Every program on the AP CSP exam is written in the exam reference sheet's notation, in text and in blocks, and Big Idea 3, Algorithms and Programming, is 30 to 35 percent of the multiple-choice section. Topic 3.1 asks students to determine the value of a variable as a result of an assignment (AAP-1.B). The CED spells the rule out: the arrow "evaluates expression and then assigns a copy of the result to the variable", and the value stored "will be the most recent value assigned" (AAP-1.B.2 and AAP-1.B.3).
The common mistake is to read b ← a as "b is a", a link that keeps them equal. It is an action that happens once: work out the right side, copy the result into the left side, move on. That is why a swap needs a third variable. Without one, the first assignment destroys the value the second one needs.
Topic 3.3 adds expressions (AAP-2.C). Multiplication, division and MOD happen before addition and subtraction. a MOD b is the remainder, defined on the sheet for a 0 or more and b more than 0. Division with / gives the ordinary result, so 17 / 5 is 3.4. Students who know Java or older Python may expect 3. The tracer follows the sheet, and its Outside the sheet page lists every choice it makes where the sheet says nothing.
| Students ask | A good answer |
|---|---|
| Isn't b ← a the same as b = a in math? | No. In math, = says two things are always equal. The arrow is an action: copy once, now. |
| Why does Not yet show me the answer? | So the trace can keep going. Write the right value in the table and look for the reason before the next ? line. |
| Does the exam use = or ←? | The arrow, for assignment. The exam uses = to compare two values, as in IF(a = b). |
| What is 7 MOD 7? | 0: 7 divides evenly, so there is no remainder. |
Lesson sequence
| Minutes | Stage | What you do | What students do |
|---|---|---|---|
| 0 to 7 | Warm-up Hook | Show the title, essential question and Today I can slides (about 1 minute). Write the CED's own example on the board: a ← 1, b ← a, a ← 2, DISPLAY(b). Ask everyone to vote with fingers, 1 or 2, and to say why. Do not settle it yet. Then have students open the link or scan the QR code on the worksheet, and hand out the exam reference sheet: this notation is the one on the exam. | Vote 1 or 2 with a reason, then open the tracer. |
| 7 to 15 | Direct instruction (I do) Model it: the arrow copies | Show the vocabulary and What the arrow does. On the projector, press Step through the starter program. Line 2, best ← score, copies 10 into best; the Variables panel marks best CHANGED. At line 3 the tracer stops: Line 3 is next. What will score be after it runs? Take answers from the room, type one in and press Check. If it is wrong, the tracer says Not yet. It was 15. and runs the line. At line 5 it asks what DISPLAY(best) will show: 10, because best got a copy of the old score, and changing score later did not touch it. Go back to the board: the warm-up displays 1, for the same reason. The CED says the variable "will be the most recent value assigned" (AAP-1.B.3). It's working when: Step stops at a line with a ? in front of it and asks before the line runs; the answer box takes a number or text. Back steps back one line at a time, so a step can be watched again. | Predict out loud at each ? line, and fill in the first rows of the trace table. |
| 15 to 25 | Guided practice (We do) Swapping two values | Students choose Example, then Swapping two values. Before stepping, they predict what the first try, lines 1 to 6, displays. Step together. The first try, x ← y then y ← x, displays 8 and 8: by the time y ← x runs, x already holds 8, and the 3 is gone. The second try saves x in temp first and displays 8 and 3. Open the Trace table tab (A row for each change) and compare it with the worksheet's table, row by row. Ask: what would happen with three variables to rotate? | Predict, step through both swaps, and copy the trace table onto the worksheet. |
| 25 to 38 | Independent practice (You do) Exam-style practice | Students choose Example, then Order of operations, and open Teach, then Exam question. The output and the steps stay covered until they choose. The right answer is 18 28 3 2.5. The other choice is 28 28 3 2.5, which is what the program displays if the operations are done left to right with no precedence; the tracer worked it out by running that mistake. The tracer offers only wrong choices that a real mistake produces, so here there are two; A choice of your own adds teacher-written choices, so a question can offer four like the exam's. After choosing, they step to see why. Then the same with A clock with MOD, whose answer is 1 (a reader who takes MOD as the quotient gets 0). Finish the worksheet's two written answers. Walk the room and ask the questions under What to look for. Watch for: A student who expects 17 / 5 to be 3 is thinking of whole-number division in another language. On the exam, / is ordinary division: 17 / 5 is 3.4, and 10 / 4 is 2.5. Watch for: Choosing a new Example replaces the program. The lesson's starter comes back by opening the worksheet link in a new tab. | Answer each exam question before stepping, then step to check, and write the two explanations. |
| 38 to 45 | Closure Explain it, and exit ticket | Show the last slide and ask: "After b ← a, why does changing a later leave b alone?" (The arrow stored a copy of a's value in b at that moment. b and a are two separate variables, and each holds only its most recent value.) Ask the essential question again, then hand out the exit ticket. | Answer out loud, then answer the exit ticket on their own. |
What to look for
Ask these while students work. A student who has understood the lesson can answer them without help:
- What does b hold right after b ← a? And after a changes?
- Which line of the first swap destroyed a value?
- Why does the second swap need temp?
- What is 23 MOD 4, and why?
- Where would a student who reads left to right go wrong in Order of operations?
Cross-curricular extensions
- Math: MOD is the remainder from long division. Find n MOD 2 for n from 1 to 10. What does it tell you about n?
- Computer science: write the starter program in a language you know. Does it display the same three values?
- Science: a lab notebook records the most recent reading of each instrument. Compare a variable to a notebook entry that gets overwritten.
- Careers: software testers trace code by hand to find where a value went wrong. List two questions a tester asks at each line.
Vocabulary
| variable | A name in a program that holds one value at a time. Giving it a new value replaces the old one. |
| assignment | The arrow, a ← expression: work out the expression, then store a copy of the result in a. |
| expression | Values, variables and operators that work out to one value, like score + 5. |
| MOD | The remainder after dividing: 17 MOD 5 is 2. On the exam, a MOD b uses a 0 or more and b more than 0. |
| trace | Following a program line by line and writing down what each variable holds. |
| trace table | A table with a column for each variable and a row each time something changes. |
| exam reference sheet | The pages of notation given to every student on the AP CSP exam. Every exam program uses it. |
Differentiation
English learners
- Post the vocabulary with a picture for each word: a labeled box for variable, a photocopier for assignment.
- Read each line aloud as a sentence before stepping: "b gets a copy of a."
- Let students answer the tracer's questions with numbers only.
Students with IEPs or 504 plans
- Where the IEP allows a modified assignment, have the student fill only the trace table and answer one written question.
- Give the worksheet with the variable columns already labeled.
- Pair students: one steps and types, the other fills in the trace table.
- Read the exit ticket aloud, or let students answer by pointing at the trace table.
Students who need more support
- Give the analogy on the board: b ← a photocopies a's paper into b's box. Writing on a's paper later does not change b's copy.
- Give a sentence starter: "After line ___, ___ holds ___ because ..."
- Check in at minute 22: is the student writing a row for every change, not just the last value?
Students ready for more
- Write a three-line program whose output looks surprising, and test it on a partner with Copy link.
- Rotate three values, a to b, b to c and c to a, with one extra variable. How many assignments does it take?
- Choose Example, Copying a list. Predict, then step. Why does LENGTH(listB) stay 3? (The sheet copies a whole list too; a later lesson in this series is about lists.)
Adapting for other grades
Younger students: Before AP, in grades 7 and 8 or a first programming course, do the warm-up and the swap together, skip MOD, and score only the first two rubric rows (out of 8; 6 or more meets the objectives).
Older students: For a college course, compare the sheet's copy rule with a language students know: in Python, b = a on a list makes b and a name the same list, and the sheet says the opposite. Ask what each choice makes easier and harder.
Pseudocode Tracer: Assignment Is a Copy
Student worksheet
Name: ______________________________ Date: ______________
Open the tracer: scan the QR code, or go to mytekdev.com/try/pseudocode?lesson=assignment-is-a-copy
Essential question: When the reference sheet's arrow runs, what exactly does the variable on its left hold afterward?
Warm-up: a ← 1, b ← a, a ← 2, DISPLAY(b). My vote: ____ because ______________________________
Trace table for Swapping two values (first try), one row for each change:
| Line | x | y | Displayed |
|---|---|---|---|
| 1 | |||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | |||
| 6 |
1. Which line destroyed the value 3 in the first swap? Explain.
2. In Order of operations, the choice 28 28 3 2.5 is wrong. What mistake gives that answer?
Pseudocode Tracer: Assignment Is a Copy
Exit ticket
Name: ______________________________
1. x ← 4, y ← x, x ← x + 3, y ← y * 2, DISPLAY(x), DISPLAY(y). What is displayed? (A) 7 8, (B) 14 14, (C) 7 14.
2. What does DISPLAY(17 MOD 5) display? (A) 3, (B) 3.4, (C) 2.
3. Explain why a swap of two variables needs a third variable.
Answer key: exit ticket
Measured in the tracer: the starter displays 15, 10 and 4. Swapping two values displays 8 8 for the first try and 8 3 with temp. Order of operations displays 18 28 3 2.5, and the no-precedence reading gives 28 28 3 2.5. Every choice was worked out by running a program, the question as written and each wrong choice with its mistake built in: question 1's B is the program with y linked to x, and C is y taking x's newest value; question 2's A is MOD read as the quotient, and B is 17 / 5.
| Question | Answer | Why |
|---|---|---|
| 1 | A | y got a copy of 4, so x ← x + 3 changes only x. Then y doubles to 8. |
| 2 | C | MOD is the remainder: 17 = 3 × 5 + 2. |
| 3 | Saving one value first | Full credit for: the first assignment replaces one value, so it must be copied into a third variable before it is lost. |
Rubric
Score each row from 1 to 4.
Name: ______________________________
| Criteria | 4 Exceeds | 3 Meets | 2 Approaching | 1 Beginning |
|---|---|---|---|---|
| Traces assignments | Fills every row of the trace table correctly and predicts each ? line before checking. | Fills the trace table correctly, with at most one slip. | Fills some rows, or only the final values. | Cannot yet trace the assignments. |
| Explains copy, not link | Explains why b keeps its value and why the first swap loses one, in their own words, using the trace table as evidence. | Explains why b keeps its value, with a reason. | Says b keeps its value without saying why. | Does not explain. |
| Evaluates expressions | Answers both exam questions correctly and explains what the tempting wrong choice got wrong. | Answers both exam questions correctly. | Answers one correctly. | Answers neither correctly. |
Total: ____ / 12. A score of 9 or more meets the objectives.
Standards
The AP CSP Course and Exam Description topics and learning objectives this lesson teaches, with the CSTA 2017 standard it meets. Students trace assignments in the exam reference sheet's notation and evaluate its expressions.
| Framework | Code | Grades | Standard | How the lesson meets it |
|---|---|---|---|---|
| AP CSP CED 2023 | AAP-1.B | 9-12 (Topic 3.1) | Determine the value of a variable as a result of an assignment. | Students predict, then check, the value of each variable after every assignment in the starter and the swap, including the CED's own b ← a example. |
| AP CSP CED 2023 | AAP-2.C | 9-12 (Topic 3.3) | Evaluate expressions that use arithmetic operators. | Students evaluate expressions with precedence, MOD and division in exam-style questions, and explain what the tempting wrong choice got wrong. |
| CSTA 2017 | 2-AP-11 | 6-8 | Create clearly named variables that represent different data types and perform operations on their values. | Students follow named variables through assignments and operations, and see that each holds one value at a time. |
Checked October 2026 against: AP Computer Science Principles Course and Exam Description, effective Fall 2023, CSTA 2017 progression chart, CSTA 2017 to 2026 crosswalk.
Optional: save student work in a free class
The whole lesson runs at the link on the worksheet, with no accounts and no sign-up. Work stays in the browser tab until it is closed. Copy link, at the top of the tracer, also keeps a program exactly as it is, in the link itself.
To keep students' work, and see every student's programs in one place, make a free class. It takes about ten minutes, once, and covers every lesson in this series: mytekdev.com/tools/class-setup
Students in a class open mytekdev.com/tools/ap-csp-pseudocode-tracer/lessons/assignment-is-a-copy/start instead of the worksheet link. Each one gets their own copy of the program, and the same link reopens it next time. A student who started at the worksheet link and then signs up keeps what they made.
The Pseudocode Tracer runs the notation of the AP Computer Science Principles Exam Reference Sheet. AP is a trademark registered by College Board, which is not affiliated with, and does not endorse, this site or these lessons.