UESL 3.1 Homework
Popcorn
Checkpoint challenge. Language: Python.
Prediction: stars = 12, checkpoint_stars = 8. stars starts at 8, and checkpoint_stars = stars copies the value 8 at that moment. Then stars is reassigned to 8 + 4 = 12, but nothing reassigns checkpoint_stars.
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 # copies the value 8, not a link to stars
stars = stars + 4 # right side first: 8 + 4 = 12, then assign to stars
print(stars)
print(checkpoint_stars)
Actual output: 12, then 8. Matches the prediction.
Why they differ: a checkpoint stores the value at the moment of assignment. Reassigning stars replaces only the value of stars. checkpoint_stars keeps 8 until something assigns to it again.
MCQ
| **MCQ 3.1: 4/4 | answers: B,A,C,B** |
- B (string).
"007"is in quotes, and text keeps the leading zeros. As an integer it would become 7. - A (8).
checkpoint ← starscopied 8. Settingstars ← 12later doesn’t changecheckpoint. - C (
←). In AP pseudocode the arrow assigns.=tests equality in AP pseudocode (it assigns in Python), and==is Python’s equality test. - B (when reassigned/recalculated). A total is a stored result, not a live formula. Changing a level’s stars or displaying the total doesn’t update it. Only a new assignment does.
Homework
Build your UESL star counter. Language: Python.
game_name is a string, reduced_motion is a Boolean (on/off setting), and each level’s stars is an integer count. Level two gets a 5-star bonus, then the stored total is printed before and after recalculating.
Prediction: Star Sprint, True, 40, then 40 (the stored total doesn’t change by itself), then 45 after recalculating.
Code Runner Challenge
UESL 3.1 Homework - Star Sprint star counter (bonus 5)
View IPYNB Source
# CODE_RUNNER: UESL 3.1 Homework - Star Sprint star counter (bonus 5)
game_name = "Star Sprint"
reduced_motion = True
level_one_stars = 12
level_two_stars = 18
level_three_stars = 10
total_stars = level_one_stars + level_two_stars + level_three_stars
print(game_name)
print(reduced_motion)
print(total_stars)
# add the bonus to level two
bonus = 5
level_two_stars = level_two_stars + bonus
# the stored total was calculated before the bonus, so it is still 40
print(total_stars)
# recalculate from the levels to pick up the bonus
total_stars = level_one_stars + level_two_stars + level_three_stars
print(total_stars)
Actual output: Star Sprint, True, 40, 40, 45. Matches the prediction.
| Total | Predicted | Actual |
|---|---|---|
| Original | 40 | 40 |
| Stored (after bonus, before recalculating) | 40 | 40 |
| Recalculated | 45 | 45 |
Tests
Language: Python. Each test starts from fresh values.
Test 1: Bonus 5 is the homework cell above: 40 → 40 → 45.
Test 2: Restart with bonus 0
Prediction: 40, 40, 40. Level two stays at 18, so recalculating gives the same total.
Code Runner Challenge
UESL 3.1 Test - restart with bonus 0
View IPYNB Source
# CODE_RUNNER: UESL 3.1 Test - restart with bonus 0
game_name = "Star Sprint"
reduced_motion = True
level_one_stars = 12
level_two_stars = 18
level_three_stars = 10
total_stars = level_one_stars + level_two_stars + level_three_stars
print(total_stars)
bonus = 0
level_two_stars = level_two_stars + bonus
print(total_stars)
total_stars = level_one_stars + level_two_stars + level_three_stars
print(total_stars)
Actual output: 40, 40, 40.
| Test | Bonus | Expected | Actual | Pass |
|---|---|---|---|---|
| Main | 5 | 40, 40, 45 | 40, 40, 45 | Yes |
| Restart | 0 | 40, 40, 40 | 40, 40, 40 | Yes |
With bonus 5, the middle line shows the stored total lagging behind the new level-two value until it’s recalculated. With bonus 0 nothing changes, so all three match. Assignment vs. comparison: total_stars = ... assigns a new value; total_stars == 45 would only check it and change nothing.
Design Thinking
| Step | Notes |
|---|---|
| Need | Some players need to play without distracting motion. |
| Goal | Make motion adjustable so more players can enjoy the game, and keep the star count correct after bonuses. |
| Considered | A settings toggle stored as a Boolean (reduced_motion = True / False), versus a text setting like "on" / "off" that could be misspelled. Went with the Boolean. |
| Prototype | This notebook stores the player’s choice in reduced_motion and tracks stars per level. |
| Test / revision | My first version computed updated_total = stored_total + 5, so level two’s stars never actually changed. I revised it to add the bonus to level_two_stars and recalculate the total from the levels, then reran both bonus cases. |
Reduced motion should be the player’s choice because comfort and accessibility are different for everyone. Motion that’s fine for one player can make another feel sick or lose focus.