UESL 3.1 Homework
Popcorn
Prediction: stars will be 12 and checkpoint_stars will be 8.
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)
Actual output: 12, then 8.
Why they differ: checkpoint_stars = stars copied the value 8 at that moment. The next line, stars = stars + 4, gives stars a new value (12), but it never touches checkpoint_stars, so the checkpoint keeps the earlier value.
MCQ
| # | Question | My answer |
|---|---|---|
| 1 | Best type for the player tag "007" |
B string, because text keeps the leading zeros |
| 2 | checkpoint after stars ← 8, checkpoint ← stars, stars ← 12 |
A 8 |
| 3 | AP operator that assigns a value | C ← |
| 4 | When a previously stored total changes | B when it is reassigned or recalculated |
MCQ 3.1: 4/4 | answers: B,A,C,B
Homework
My UESL star counter, adapted from Example C. It stores the game name, a reduced-motion setting, and three separate level-star variables. It adds a bonus of 5 to level two, prints the stored total, then recalculates it.
Prediction: UESL Comet Dash, True, 40, 40, 45
Code Runner Challenge
UESL 3.1 Homework - Build my star counter
View IPYNB Source
# CODE_RUNNER: UESL 3.1 Homework - Build my star counter
game_title = "UESL Comet Dash"
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_title)
print(reduced_motion)
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)
Actual output: UESL Comet Dash, True, 40, 40, 45
The second 40 is the stored total. Adding the bonus changed level_two_stars to 23, but total_stars still held the old sum until the program recalculated it.
Tests
Each test starts from fresh values: 12, 18, 10.
| Test | Bonus | Predicted totals (original, stored, updated) | Actual totals |
|---|---|---|---|
| 1 | 5 | 40, 40, 45 | 40, 40, 45 |
| 2 | 0 | 40, 40, 40 | 40, 40, 40 |
Code Runner Challenge
UESL 3.1 Tests - Bonus of 5, then bonus of 0
View IPYNB Source
# CODE_RUNNER: UESL 3.1 Tests - Bonus of 5, then bonus of 0
# Test 1: bonus of 5
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)
level_two_stars = level_two_stars + 5
print(total_stars)
total_stars = level_one_stars + level_two_stars + level_three_stars
print(total_stars)
# Test 2: restart with a bonus of 0
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)
level_two_stars = level_two_stars + 0
print(total_stars)
total_stars = level_one_stars + level_two_stars + level_three_stars
print(total_stars)
Result: Test 1 printed 40, 40, 45. Test 2 printed 40, 40, 40. With a bonus of 0, recalculating gives the same total, which shows the recalculation only changes the result when a level’s stars actually change.
Design Thinking
- Player need: some players find fast animation distracting or uncomfortable and need a calmer screen to enjoy the game.
- Goal: a star counter where a player can clearly see what changed after a bonus.
- Representation I considered: one
total_starsvariable only, compared with separate level variables. I chose separate level variables so a bonus can be added to one level, and I kept the total as its own variable to show why it has to be recalculated. - Prototype: the UESL Comet Dash counter above, with
reduced_motion = Truestored as a Boolean. - Test: Test 2 (bonus of 0) confirmed the totals stay at
40, and Test 1 showed the stored total stays40until it is recalculated to45.
Why reduced motion should be a player choice: players have different needs. Some enjoy the animation, and others need less movement on screen. Storing it as a Boolean setting lets each player turn it on or off instead of the game deciding for everyone.