3.01 Variables and Assignments
Model a UESL game maker with variables, types and assignments in Python and College Board pseudocode.
UESL Game Maker · Mission 1 of 2
Give your game a memory
Store a player profile, preserve a checkpoint, and update a star counter.
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 needs a clear way to represent player settings and progress. A player may want reduced motion or a slower preview.
Define:
- POV: New makers need to trace each state change so a checkpoint and a live score do not get confused.
- Learning goal: Choose types, initialize meaningful variables and explain assignment order.
Ideate:
- HMW: How might a player see exactly what changed after earning a bonus?
- Activity: Predict the star counter, playtest it, then compare the stored and updated totals.
Prototype & Test: Build the examples below. Ask a peer to explain the checkpoint and suggest one useful setting. Revise from their actual feedback.
2. Lesson Plan
Objective: Model a UESL game’s state with variables and assignments.
Success criteria: Choose a suitable type, trace reassignment, and explain why a stored total must be recalculated.
Tech Talk · 3 minutes
A variable names a current value. game_title names text; level_one_stars names a count. Python names are case-sensitive, cannot begin with a digit, and cannot be keywords. Choose names that explain their purpose.
Evaluate the right side first, then assign the result to the left. stars = stars + 5 needs an initial value. Each assignment replaces the previous value; a total is a stored result, not a live formula. Python names can later refer to another type, but keeping a consistent purpose makes code clearer.
From College Board: Topic 3.1 covers representing values, choosing meaningful names/types, and tracing the latest assignment (AAP-1.A/B, pp. 63–64). The AP assignment arrow is ←; = tests equality.
3. Reference Guide
| Game-maker data | Python type/example | Why this type? |
|---|---|---|
| Game name or player tag | str: "Star Trail", "007" |
Text keeps letters and leading zeros. |
| Collected stars | int: 10 |
Count whole items. |
| Preview speed multiplier | float: 0.75 |
Allow a fractional speed. |
| Reduced-motion setting | bool: True |
A true/false choice. |
| Multiple level scores | list: [10, 20, 15] |
A collection, introduced in 3.2. |
Initialization gives a name its first value; reassignment replaces it. Python needs no separate typed declaration. "10" is text, while 10 is numeric: Python input() returns text, so int("10") + 5 gives 15 (Python input() documentation).
| Operation | Python | College Board pseudocode |
|---|---|---|
| Initialize | stars = 10 |
stars ← 10 |
| Update | stars = stars + 5 |
stars ← stars + 5 |
| Compare | stars == 10 |
stars = 10 |
| Display | print(stars) |
DISPLAY(stars) |
AP uses Boolean values true/false; the OCS runner spells them TRUE/FALSE. College Board’s DISPLAY adds a space; this runner displays each call on a new line. Our paired examples print the same values in the same order without nonstandard text-plus-number expressions.
4. Code Examples
Playtest controls: In C and Popcorn, select Python or Pseudocode to load the matching program. Pseudocode comments explain each line. Edits stay while switching; Save keeps the current code and language after reload. The trash button restores the Python starter. Changing one version does not translate your edits into the other.
A. Simple · Set up a player profile
game_title = "UESL Star Trail"
player_tag = "007"
preview_speed = 0.75
reduced_motion = True
print(game_title)
print(player_tag)
print(preview_speed)
print(reduced_motion)
Output: UESL Star Trail, 007, 0.75, True. These are configuration values; applying them to a game would require connecting them to its controls.
B. Intermediate · Preserve a checkpoint
stars = 10
checkpoint_stars = stars
stars = stars + 5
checkpoint_stars = checkpoint_stars + 2
print(stars)
print(checkpoint_stars)
Output: 15, then 12. Both started at 10, then changed independently. A checkpoint stores the value at the moment of assignment.
C. Complex · Playtest a star bonus
Predict the original, stored and recalculated totals. Then change the bonus from 5 to 0.
Code Runner Challenge
UESL 3.1 - Playtest the star counter
View IPYNB Source
# CODE_RUNNER: UESL 3.1 - Playtest the star counter
game_title = "UESL Star Trail"
level_one_stars = 10
level_two_stars = 20
level_three_stars = 15
total_stars = level_one_stars + level_two_stars + level_three_stars
print(game_title)
print(total_stars)
level_two_stars = level_two_stars + 5
print(total_stars)
total_stars = level_one_stars + level_two_stars + level_three_stars
print(total_stars)
Both versions output: UESL Star Trail, 45, 45, 50.
| Star-counter snapshot | Before bonus | After bonus, before recalculation | After recalculation |
|---|---|---|---|
| Second level | 20 | 25 | 25 |
| Stored total | 45 | 45 | 50 |
5. Hacks & Practice Tasks
Create your homework page
- In your portfolio repository, create
navigation/homework/3-1.md; create the folders if needed. -
Paste this frontmatter at the top, replacing
your-github-id:--- layout: post title: UESL 3.1 Homework author: your-github-id permalink: /homework/3-1/ --- -
Add
## Popcorn,## MCQ,## Homework,## Testsand## Design Thinking. Copy the Popcorn 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-1/page and submit its full URL through the assignment form below. IncludeMCQ 3.1: __/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.
Popcorn Hack · Checkpoint challenge
Two minutes: Predict the live stars and checkpoint stars. Run, then explain why they differ.
Code Runner Challenge
UESL 3.1 Popcorn - Keep the checkpoint
View IPYNB Source
# CODE_RUNNER: UESL 3.1 Popcorn - Keep the checkpoint
stars = 8
checkpoint_stars = stars
stars = stars + 4
print(stars)
print(checkpoint_stars)
Checkpoint debrief · reveal after predicting
Both versions display 12, then 8. The checkpoint holds the earlier value.
MCQ Check · Maker decisions
Record A, B or C for each before revealing the key.
- A player tag is
"007". Best type? A integer · B string · C Boolean. - After
stars ← 8,checkpoint ← stars,stars ← 12, what ischeckpoint? A 8 · B 12 · C 20. - Which AP operator assigns a value? A
=· B==· C←. - A bonus changes a level’s stars. When does a previously stored total change? A Automatically · B When reassigned/recalculated · C When displayed.
MCQ answers and explanations
B, A, C, B. Text preserves 007; the checkpoint copied 8; the arrow assigns; displaying a total does not recalculate it. Count one point per correct answer and record your actual score out of 4.
Homework Hack · Build your UESL star counter
- Choose a game name and a reduced-motion Boolean setting. Use separate level-star variables starting at
12,18,10; print the name, setting and total. - Add a bonus of
5to level two. Print the stored total, then recalculate and print it again. - Record predictions and actual results: original/stored total
40, updated total45. Restart with bonus0; all three totals should be40. - Design-thinking note: Name a player’s need, your goal, a setting/representation you considered, the prototype you built, and one test or revision. Explain why reduced motion should be a player choice.
Next mission: 3.2 replaces separate level variables with a collection. What would 100 separate variables cost a game maker to maintain?
6. Grading Plan (1 Point Total)
| Part | Points | Evidence |
|---|---|---|
| Popcorn | 0.2 | Prediction, working code and checkpoint explanation. |
| MCQ | 0.2 | 0.05 per correct answer; record answers and score. |
| Homework | 0.3 | Suitable names/types and correct bonus/recalculation. |
| Tests | 0.2 | Both bonus cases and actual output explained. |
| Design thinking | 0.1 | Player need, choices, prototype and test/revision. |
Quick validation: All sections present; fresh starting values; totals match; explain assignment versus comparison; published link opens.
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.
- 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.1, printed pp. 63–64; AAP-1.A/B: curriculum scope.
- College Board, 2026 AP CSP Exam Reference Sheet, printed p. 1: assignment, display and equality.
- Python documentation: introduction: assignment, numbers, text and lists.
- 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 John Mortensen’s original variables 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.
game_title ← "UESL Star Trail" // Store the game name. level_one_stars ← 10 // Store the first level's stars. level_two_stars ← 20 // Store the second level's stars. level_three_stars ← 15 // Store the third level's stars. total_stars ← level_one_stars + level_two_stars + level_three_stars // Calculate the starting total. DISPLAY(game_title) // Show the game being tested. DISPLAY(total_stars) // Show the original total: 45. level_two_stars ← level_two_stars + 5 // Award a bonus in the second level. DISPLAY(total_stars) // The previously stored total stays 45. total_stars ← level_one_stars + level_two_stars + level_three_stars // Recalculate after the bonus. DISPLAY(total_stars) // Show the updated total: 50. stars ← 8 // Initialize the live star count. checkpoint_stars ← stars // Save the current count at a checkpoint. stars ← stars + 4 // Collect four more stars without changing the checkpoint. DISPLAY(stars) // Show the live count: 12. DISPLAY(checkpoint_stars) // Show the saved count: 8.Submit Assignment
Need to update a submission later? Open the submissions dashboard.