Skip to main content
CSP LabBy Educator Today
Demonstration view (not a real account role)
Demo — saved on this device

Sample lab · public practice

Club capacity investigation

Trace the authored countAvailable procedure through a list of club capacities. Revisit the sample lesson at any time.

Loading saved work…

Interactive example — not a general interpreter

Brief

Scenario

The student council keeps a list of how many places remain in each club. A student who needs a certain number of places — perhaps for themselves and two friends — wants to know how many clubs could take them.

Learning objectives

  • Trace iteration (FOR EACH) and selection (IF) through a list.
  • Explain what the minimum parameter does and why it makes the procedure reusable.
  • Connect a list of capacities to a useful task for students.

Instructions

  1. Read the procedure in the centre panel.
  2. Enter a prediction for the returned value, then select Predict.
  3. Use Step to move one element at a time, or Run trace to finish.
  4. Try each preset dataset and a minimum of your own.
  5. Check the authored tests, then write your reflection.

Checkpoints

Checkpoints met0 of 4
  • Make a prediction(not yet)
  • Trace to the RETURN line(not yet)
  • Check the authored tests(not yet)
  • Write a reflection(not yet)

Interactive example

AP-style pseudocode · countAvailable
PROCEDURE countAvailable(capacities, minimum){  count ← 0  FOR EACH places IN capacities  {    IF (places ≥ minimum)    {      count ← count + 1    }  }  RETURN count}
Dataset (teacher-authored presets)

Preset minimum. You may enter any nonnegative whole number.

Predict before you trace.

Step0 of 5
Current elementnot started
count—
Trace table for countAvailable([0, 5, 2, 8], 3)
Positionplaces (value)places ≥ minimumcount after
count ← 0. Select Step to examine the first element.

Result

Finish the trace to reach RETURN count.

Support

Notes

Hints

    Hints are written in advance. There is no AI tutor.

    Authored tests

    • [0, 5, 2, 8], 3 → expected 2Several matches: two clubs have at least 3 places left.Not checked
    • [0, 5, 2, 8], 2 → expected 3Equal to the threshold: 2 ≥ 2 is true, so the club with 2 places counts.Not checked
    • [0, 5, 2, 8], 9 → expected 0No matches: no club has 9 or more places.Not checked
    • [3, 3], 3 → expected 2Boundary: every value equals the minimum, and ≥ includes equality.Not checked
    • [], 3 → expected 0Robustness test: the loop body never runs, so count stays 0. This is an authored edge case, not a Create task suitability claim.Not checked

    Reflection

    This demo copy is not sent to a teacher

    To hand work to your teacher, open the assignment from your class after signing in. Completing practice here only saves a completion mark on this device.

    Meet all 4 checkpoints first (0 of 4 met).