Popcorn Hack: Checkpoint Challenge

Prediction: stars becomes 12 (8 + 4) and checkpoint_stars stays 8, because the checkpoint copied the value before the bonus was added.

Code Runner Challenge

UESL 3.1 Popcorn - Keep the checkpoint

View IPYNB Source
# CODE_RUNNER: UESL 3.1 Popcorn - Keep the checkpoint

# Prediction: 12, then 8
stars = 8
checkpoint_stars = stars      # copies the CURRENT value (8)
stars = stars + 4             # only stars changes
print(stars)
print(checkpoint_stars)
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Actual output: 12, then 8.

Why they differ: Assignment copies the value at that moment. checkpoint_stars was set to 8 before stars was reassigned, so the later update to stars never touches it.

MCQ Check: Maker Decisions

# Question My answer Why
1 Best type for the player tag "007" B (string) Text keeps the leading zeros.
2 Value of checkpoint after stars ← 8, checkpoint ← stars, stars ← 12 A (8) The checkpoint copied 8 before stars changed.
3 AP operator that assigns a value C (←) = tests equality in AP pseudocode.
4 When does a stored total change after a level changes? B (when reassigned/recalculated) A stored total is a result, not a live formula.
**MCQ 3.1: 4/4 answers: B,A,C,B**

Homework Hack: Build Your UESL Star Counter

Game name and reduced-motion setting, three level-star variables (12, 18, 10), a bonus of 5 on level two, then the stored total versus the recalculated total. (The OCS runner prints Booleans as TRUE/FALSE.)

Code Runner Challenge

UESL 3.1 Homework - Build your UESL star counter

View IPYNB Source
# CODE_RUNNER: UESL 3.1 Homework - Build your UESL star counter

game_name = "Star Trail"
reduced_motion = True          # a player choice, not a default forced on everyone

level_one_stars = 12
level_two_stars = 18
level_three_stars = 10

# Stored total: a RESULT calculated at this moment, not a live formula
total_stars = level_one_stars + level_two_stars + level_three_stars

print(game_name)
print(reduced_motion)
print(total_stars)             # original total

# Bonus of 5 on level two
bonus = 5
level_two_stars = level_two_stars + bonus

print(total_stars)             # stored total is still the old value

# Recalculate so the total matches the levels again
total_stars = level_one_stars + level_two_stars + level_three_stars
print(total_stars)             # updated total
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Prediction: Star Trail, True, 40, then 40 (stored, not recalculated), then 45 (recalculated).

Actual output: Star Trail, True, 40, 40, 45.

Tests: Both Bonus Cases

Each test re-initializes every variable so nothing carries over from the previous cell.

Test 1: bonus = 5

Prediction: original 40, stored after bonus 40, recalculated 45.

Code Runner Challenge

UESL 3.1 Test 1 - bonus of 5

View IPYNB Source
# CODE_RUNNER: UESL 3.1 Test 1 - bonus of 5

level_one_stars = 12
level_two_stars = 18
level_three_stars = 10
bonus = 5

total_stars = level_one_stars + level_two_stars + level_three_stars
print(total_stars)                 # original total

level_two_stars = level_two_stars + bonus
print(total_stars)                 # stored total (not recalculated yet)

total_stars = level_one_stars + level_two_stars + level_three_stars
print(total_stars)                 # recalculated total
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Actual output: 40, 40, 45. The stored total only changes after the reassignment on the last line.

Test 2: bonus = 0

Prediction: all three totals are 40, since adding 0 changes nothing.

Code Runner Challenge

UESL 3.1 Test 2 - bonus of 0

View IPYNB Source
# CODE_RUNNER: UESL 3.1 Test 2 - bonus of 0

level_one_stars = 12
level_two_stars = 18
level_three_stars = 10
bonus = 0

total_stars = level_one_stars + level_two_stars + level_three_stars
print(total_stars)                 # original total

level_two_stars = level_two_stars + bonus
print(total_stars)                 # stored total

total_stars = level_one_stars + level_two_stars + level_three_stars
print(total_stars)                 # recalculated total
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Actual output: 40, 40, 40. Recalculating is still correct, it just produces the same number because the bonus was zero.

Design Thinking

  • Player need: Some players are sensitive to motion, so a game needs a setting they can turn on for themselves.
  • Goal: Track each level’s stars clearly and always know whether the total I display is current.
  • Representation considered: One combined total_stars variable versus separate level variables. I kept separate level variables so a single level’s change is easy to trace, and a stored total that I recalculate on purpose.
  • Prototype built: The star counter above, with a reduced_motion Boolean, a bonus on level two, and a before/after recalculation.
  • Test and revision: My first version printed the total right after the bonus and showed the old 40, which looked like a bug. I added the explicit recalculation line and comments explaining that a stored total is not a live formula.
  • Why reduced motion should be a player choice: Needs differ from player to player. Forcing it on everyone removes effects some players enjoy, and leaving it off by default can make the game uncomfortable for others. A setting respects both.

Submission notes line: MCQ 3.1: 4/4 | answers: B,A,C,B