3.02 Data Abstractions
Model a UESL game maker with lists, indices and data abstraction in Python and College Board pseudocode.
UESL Game Maker · Mission 2 of 2
Build a collection of levels
Grow Star Trail without writing a new variable and calculation for every level.
Classroom prototype: UESL Star Trail, a game in which players collect stars across levels.
UESL’s foundation supports community and opportunities through gaming for people with intellectual and developmental disabilities. Our examples model a game maker’s settings and scores; ask players what helps them enjoy a game.
1. LxD Cycle Process
Empathize: A game maker wants to add or reorder levels without losing track of each level’s stars.
Define · POV and goal: New makers need one understandable collection in level order. Read, update and extend it; explain the maintenance work it avoids.
Ideate · HMW: How might one star counter support three levels, four levels, or none yet? Extend the 3.1 prototype with a list.
Prototype & Test: At each stop below, predict → run → change → explain. Have a peer locate the second level in both languages, check the labels, and test an empty project.
2. Lesson Plan
Objective: Represent UESL level data with a list and use it to manage complexity.
Success criteria: Access the intended element, update/append correctly, and explain why the same total calculation works for different lengths.
Tech Talk · Start with a collection
Data abstraction lets a name and operations stand for a collection, without requiring code to manage its storage details. In 3.1, each level had a separate variable. Here, level_stars = [10, 20, 15] represents all levels’ star counts.
A list is ordered, with an element at each index. Python’s first index is 0; College Board pseudocode starts at 1.
A. Popcorn warm-up · Find the level (1 minute)
Predict: What will the three output lines show: the first level’s stars, the second level’s stars, and the number of levels?
Run → change: Run Python, then switch to Pseudocode and compare. Change only the first value from 10 to 14 in either version. Which output changes, and why does the length stay the same?
Runner controls · languages, saving and reset
Each runner offers Python and Pseudocode with equivalent output and a comment explaining every pseudocode line. Switching keeps your edits in each language; it does not translate them. Save keeps the selected code/language after reload; Trash restores the Python starter. College Board's DISPLAY adds a space; OCS shows each call on a new line.
Code Runner Challenge
UESL 3.2 Warm-up - Find the level
Warm-up debrief · reveal after predicting
Both versions display 10, 20, then 3. Changing the first value to 14 changes only the first output. Replacing a value does not add a level. Python index 1 and AP index 2 both select the second level.
Explain to a partner: Point to one element, its index, and the list’s length. This warm-up is practice; the checkpoint below is the graded Popcorn task.
3. Reference Guide
Index map · Star Trail’s sample levels
| Level label | Forest | Cavern | Summit |
|---|---|---|---|
| Stars | 10 | 20 | 15 |
| Python index | 0 | 1 | 2 |
| AP index | 1 | 2 | 3 |
For length n, nonnegative Python indices are 0 through n−1; AP indices are 1 through n. Empty lists have no readable element. An invalid AP index terminates the program; Python raises IndexError for an out-of-range index (AP list rules).
Read, replace and grow
| Operation | Python | College Board pseudocode |
|---|---|---|
| Create a collection | level_stars = [10, 20, 15] |
level_stars ← [10, 20, 15] |
| Empty project | level_stars = [] |
level_stars ← [] |
| Read the second level | level_stars[1] |
level_stars[2] |
| Replace its count | level_stars[1] = 25 |
level_stars[2] ← 25 |
| Count levels | len(level_stars) |
LENGTH(level_stars) |
| Add at the end | level_stars.append(12) |
APPEND(level_stars, 12) |
| Insert at position two | level_stars.insert(1, 8) |
INSERT(level_stars, 2, 8) |
| Remove position two | level_stars.pop(1) |
REMOVE(level_stars, 2) |
B. Popcorn checkpoint · Extend the level sequence (2 minutes)
Predict: Write the new collection and level count before running. Which AP index selects the same second level as Python index 1?
Run → change: Check both languages. Change the appended value from 5 to 8 in one version and rerun. Explain why updating an element keeps the length, while appending increases it. Record the original prediction, code, output and AP index in your homework’s Popcorn section.
Code Runner Challenge
UESL 3.2 Popcorn - Extend the level sequence
Checkpoint debrief · reveal after predicting
Both versions display [6, 12, 12, 5], then 4. AP index 2 and Python index 1 select the second level.
Changed version: Appending 8 instead gives [6, 12, 12, 8], still four levels. Inserting adds an element at a chosen position and shifts later elements; removing closes the gap and decreases the length by one.
Other representations and copying
Values may repeat and types may mix, such as ["Forest", 10]; our counter keeps every element numeric so addition makes sense. Lists are also called arrays in some languages.
A string is an ordered character sequence: Python "Forest"[0] is "F". Strings cannot be edited character by character; lists can be changed. Copying: Python other = level_stars shares the same list; level_stars.copy() makes a separate shallow copy, sufficient for these numbers. AP other ← level_stars copies the list (Python lists, AP assignment).
Quick partner check: If Python uses other = level_stars, would changing other[0] also affect level_stars? Explain before opening the answer.
Copying debrief
Yes: both names refer to the same Python list. Use other = level_stars.copy() for a separate copy of these numbers. AP other ← level_stars copies the list.
4. Code Examples
C. Apply the abstraction · Total the whole game
The supplied loop visits each level’s star count. Predict: How many levels and total stars will it display? Run → change: Try [10, 20, 15, 12], then [], changing only the list. Explain why the loop needs no new line for a fourth level.
Code Runner Challenge
UESL 3.2 - Total the level collection
View IPYNB Source
# CODE_RUNNER: UESL 3.2 - Total the level collection
level_stars = [10, 20, 15]
total_stars = 0
for stars in level_stars:
total_stars = total_stars + stars
print(len(level_stars))
print(total_stars)
Both versions output: 3, then 45. Read these as level count → total stars. With [10, 20, 15, 12], expect 4, 57; with [], expect 0, 0.
total_stars before every calculation.From College Board: Topic 3.2 connects list/string representations with explaining how abstraction reduces program complexity (AAP-1.C/D, pp. 65–66). Merely storing a list is insufficient evidence: explain which repeated edits it eliminates.
5. Hacks & Practice Tasks
Create your homework page
- In your portfolio repository, create
navigation/homework/3-2.md; create the folders if needed. -
Paste this frontmatter at the top, replacing
your-github-id:--- layout: post title: UESL 3.2 Homework author: your-github-id permalink: /homework/3-2/ --- -
Add
## Popcorn,## MCQ,## Homework,## Testsand## Design Thinking. Copy the Popcorn checkpoint example and adapt Example C. Format your work like this:```python # Your UESL prototype goes here. ``` Prediction: ... Actual output: ... - Run your Python solution in the lesson or your class editor. Markdown code fences display code; they do not execute it. Record both required tests and explain the result.
- Preview, commit and push. Open your published
/homework/3-2/page and submit its full URL through the assignment form below. IncludeMCQ 3.2: __/4 | answers: __,__,__,__in the notes.
Submission rules: Initialize every test, identify the code language, include actual output, and verify your published link opens. Keep private player information out of examples.
MCQ Check · Maker decisions
Record A, B or C for each before revealing the key.
- Which AP index selects the first level? A 0 · B 1 · C the list length.
- Replacing one count changes the list length by: A 0 · B 1 · C −1.
- What does
APPEND(level_stars, 5)do? A Change level five · B Add five levels · C Add one element with value 5. - Why use a list plus traversal for 100 levels? A It always runs faster · B It avoids a separate variable and sum edit for every level · C It prevents all errors.
MCQ answers and explanations
B, A, C, B. AP starts at 1; replacement keeps the length; APPEND adds one item; the benefit here is simpler maintenance, not a guaranteed speed increase. Record your actual score out of 4.
Homework Hack · Grow your UESL game
- Refactor the 3.1 prototype into
level_stars = [12, 18, 10]. Explain that each element is one level’s collected stars, in level order. - Add
5to the second level and append7for a new level. Use Example C’s traversal to print the collection, level count and total. Expect[12, 23, 10, 7],4,52. - Test the total-only code with
[]: expect0,0. Skip the second-level update when there is no second element. - Explain the edits a list avoids compared with 100 separate variables. Add a design-thinking note: player/maker need, goal, representation considered, prototype and one actual test/revision. Suggest clear level labels so players need not understand indices.
Connection to 3.1: Changing a list still does not recalculate a previously stored total. The list organizes state; assignment and the traversal update it.
6. Grading Plan (1 Point Total)
| Part | Points | Evidence |
|---|---|---|
| Popcorn | 0.2 | Prediction, working code and correct AP index. |
| MCQ | 0.2 | 0.05 per correct answer; record answers and score. |
| Homework | 0.3 | Correct collection, update, append and traversal. |
| Tests | 0.2 | Main/empty outputs and a specific complexity explanation. |
| Design thinking | 0.1 | Player/maker need, choices, prototype and test/revision. |
Quick validation: All sections present; each test starts fresh; four levels/52 and empty/0 verified; complexity explanation and published link included.
7. Lesson Revisions & Feedback Evidence
- Feedback received: The previous runner PR was too broad for this lesson contribution.
- Revision made: Kept the changes in the two lesson pages; reused OCS runners and styles, added UESL examples and the seven-stage lesson structure.
- Teaching-flow revision: Moved a runnable warm-up after the list introduction and the graded Popcorn checkpoint after indexing/operations. Added predict/run/change prompts and revealable debriefs; removed duplicate static examples.
- Peer playtest: Pending. Record reviewer → confusion or access need → revision → actual retest result. Do not invent player feedback.
References
- College Board, AP CSP Course and Exam Description, Topic 3.2, printed pp. 65–66; AAP-1.C/D: curriculum scope.
- College Board, 2026 AP CSP Exam Reference Sheet, printed pp. 3–4: list indexing, operations and traversal.
- Python documentation: introduction: assignment, numbers, text and lists. Data structures covers list operations and copying.
- UESL Foundation and our UESL Game Maker project: community context and game-making workflow.
- OCS CSA 1.2: seven-stage lesson format. Examples here use CSP Python and pseudocode, not Java’s type rules.
Credits: Adapted by Adhvay Iyer, Ishan Shrivastava, and Rohan Chandra; based on Jaynee Chauhan, Michelle Ji and Lucas Masterson’s original data-abstraction lesson.
Submit: Published homework URL, Popcorn, MCQ answers/score, both tests and your design-thinking note. Python uses the existing OCS execution service; if it is unavailable, retry or use your class editor. Pseudocode runs in the page.
level_stars ← [10, 20, 15] // Store one star count per level, in order. DISPLAY(level_stars[1]) // Display the first level's stars; AP starts at 1. DISPLAY(level_stars[2]) // Display the second level's stars. DISPLAY(LENGTH(level_stars)) // Display the number of levels, not the sum of stars. level_stars ← [6, 9, 12] // Create three levels' star counts. level_stars[2] ← level_stars[2] + 3 // Add three stars to the second level; AP starts at 1. APPEND(level_stars, 5) // Add a fourth level with five stars. DISPLAY(level_stars) // Show all counts: [6, 12, 12, 5]. DISPLAY(LENGTH(level_stars)) // Show the new level count: 4. level_stars ← [10, 20, 15] // Store one star count per level. total_stars ← 0 // Start a fresh total for this playtest. FOR EACH stars IN level_stars // Visit the levels' counts in order. { // Begin the instructions for each visit. total_stars ← total_stars + stars // Add this level's stars. } // Finish the visit, then continue through the remaining levels. DISPLAY(LENGTH(level_stars)) // Display the number of levels: 3. DISPLAY(total_stars) // Display the combined star count: 45.Submit Assignment
Need to update a submission later? Open the submissions dashboard.