Popcorn

Code Runner Challenge

UESL 3.2 Popcorn - Extend the level sequence

Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Prediction: The second level starts at 9, then increases by 3, so it becomes 12. Appending 5 adds a new fourth level. The list should print [6, 12, 12, 5], and the length should print 4.

Actual output:

[6, 12, 12, 5]
4

AP index connection: Python index 1 selects the second level, so the matching College Board pseudocode index is 2.

Changing the appended value from 5 to 8 would print [6, 12, 12, 8] and still have length 4. Updating an existing element keeps the same length, but appending adds one new element.

MCQ

MCQ 3.2: 4/4 answers: B,A,C,B
  1. B - AP pseudocode uses index 1 for the first list element.
  2. A - Replacing one count changes the length by 0.
  3. C - APPEND(level_stars, 5) adds one element with value 5.
  4. B - A list plus traversal avoids a separate variable and sum edit for every level.

Homework

Code Runner Challenge

UESL 3.2 Homework - Grow your UESL game

Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Prediction: Level two changes from 18 to 23, and the new level with 7 stars becomes the fourth element. The collection should be [12, 23, 10, 7], the level count should be 4, and the total should be 52.

Actual output:

[12, 23, 10, 7]
4
52

Tests

Test 1 - main game with four levels.

Code Runner Challenge

Test 1 - Main game with four levels

Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Prediction: The level count should be 4, and the total should be 52.

Actual output:

4
52

Result: The traversal works after the list grows because the for loop visits every current element.

Test 2 - empty project.

Code Runner Challenge

Test 2 - Empty project

Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Prediction: The empty list has no second element, so the update is skipped. The level count should be 0, and the total should be 0.

Actual output:

0
0

Result: This test starts fresh and avoids an invalid index. The same total-only traversal still works because looping over an empty list simply runs zero times.

Complexity explanation: A list avoids creating level_one_stars, level_two_stars, level_three_stars, and so on for every level. If the game had 100 levels, I could add, remove, or reorder entries in one collection while the traversal code for counting levels and totaling stars would stay the same.

Design Thinking

Player/maker need: A UESL game maker needs to manage level scores in order without making the code harder every time a level is added.

Goal: My goal was to refactor the 3.1 prototype from separate level variables into one ordered list that can be updated, appended to, counted, and traversed.

Representation considered: I considered separate variables because they are readable for three levels, but a list is better because each element represents one level and the same loop can handle different lengths.

Prototype: I built level_stars = [12, 18, 10], added 5 to the second level, appended 7 for a new level, and used a loop to calculate the total.

Test/revision: I tested the normal four-level game and an empty project. The empty project reminded me to check len(level_stars) >= 2 before trying to update the second element.

Clear level labels should be shown in the game interface so players and makers do not need to understand list indices to know which level they are editing.