🧠Concept
Pick the right answer.
👀Code Reading
Look at the blocks. Predict what happens.
set [temp v] to (item (i) of [nums v]) replace item (i) of [nums v] with (item ((i) + (1)) of [nums v]) replace item ((i) + (1)) of [nums v] with (temp)
set [i v] to (1)
repeat ((length of [nums v]) - (1))
if <(item (i) of [nums v]) > (item ((i) + (1)) of [nums v])> then
set [temp v] to (item (i) of [nums v])
replace item (i) of [nums v] with (item ((i) + (1)) of [nums v])
replace item ((i) + (1)) of [nums v] with (temp)
end
change [i v] by (1)
end🐛Find the Bug
Something is broken. Pick the fix.
This swap is supposed to exchange items at position i and i+1 in the list. After running, both items end up with the same value. What is the bug?
replace item (i) of [nums v] with (item ((i) + (1)) of [nums v]) replace item ((i) + (1)) of [nums v] with (item (i) of [nums v])
🛠️Build It
Pick a level. Build it. Check the boxes.
Swap the first two numbers.
More
Create a list called nums and add 5 numbers manually. Write a swap script: store item 1 in temp, replace item 1 with item 2, replace item 2 with temp. Click the and verify the swap works.
Done when
The list is created with 5 numbers. After running, items 1 and 2 are exchanged. The original value of item 1 is preserved in temp and placed correctly into item 2.
Sort the list, smallest first.
More
Build a full bubble sort. Create a list nums with 6 numbers in scrambled order. Use a nested loop: outer repeat (length - 1) for passes; inner repeat (length - 1) with index i for comparisons. Inside the inner loop, if item(i) > item(i+1), perform the three-step temp swap. Display the list after each pass so you can watch it sort.
Done when
The list sorts correctly from smallest to largest. The outer and inner loops are both present. The temp variable is used for every swap. The list visibly updates pass by pass.
Count the swaps while sorting.
More
Extend the MEDIUM project. Do these steps:
1. Add a swaps variable. Add 1 to it every time a swap happens.
2. After sorting, say the total swaps.
3. Add a list sorted_steps. After each pass, add that pass's swap count to the list.
4. After sorting, say one verdict: "nearly sorted" if swaps < 3, else "very scrambled". (A 6-item list needs at most 15 swaps.)
Use this for step 1, inside the swap:
change [swaps ▾] by (1)
Done when
Swap counter is correct. Per-pass counts are recorded in sorted_steps. The final verdict message is accurate. All lists sort correctly.
Review the student's project, then check each thing they did.
Project Evaluation
0 of 4 ticked
💬Talk About It
Present your project to your teacher or a classmate.
- 1️⃣Show your swap project and point to
temp. - 2️⃣Use two numbers (for example 3 and 5): say what goes wrong without
temp, then say the three steps of the correct swap.
Watch the student present, then check each thing they did.
Presentation Checklist
0 of 3 ticked
📤Submit
Send your results to your teacher and parent.
0 of 0 answered