{
  "format": "colearn-activity-bundle/v1",
  "activities": [
    {
      "name": "workshop_sampler_2026",
      "title": "For Loops — Workshop Sampler",
      "source_type": "local",
      "sheet_url": null,
      "order_index": 1,
      "content_text": "%% Activity header\n\\title{For Loops — Workshop Sampler}\n\\name{workshop_sampler_2026}\n\\studentlevel{CS1 Python (or C++), week 5–7; comfortable with variables and conditionals; just introduced to for loops.}\n\\activitycontext{Explores counter-controlled iteration using Python for loops with range(), Turtle, C++ for loops, and trace tables. Groups work in POGIL roles. Goal: conceptual understanding of loop mechanics.}\n\\aicodeguidance{Require actual loop constructs. Reject hard-coded lists or repeated statements. Accept any valid variable names and equivalent range() arguments.}\n\\retries{3}\n\n%% Section 1: Concept check\n\\section{Explaining the Loop}{10}\n\\text{A \\textbf{counter-controlled loop} repeats a fixed number of times. In Python, for loops with range() are the standard tool.}\n\n\\question{In your own words, explain what a counter-controlled loop does and how Python's for loop with range() implements it. Give a concrete example with specific numbers.}\n  \\responsemode{answer}\n  \\textresponse{5}\n  \\sampleresponses{A counter-controlled loop runs a set number of times. Python's for loop with range(start, stop, step) handles the counting automatically. For example, range(1, 6) produces 1, 2, 3, 4, 5 — the stop value is excluded. The loop variable takes each value in turn without needing a separate counter variable.}\n  \\feedbackprompt{Accept if the response explains: (1) a fixed number of repetitions and (2) how range() generates the sequence. Nudge if they omit that stop is excluded or give no example. Flag if too vague.}\n\\endquestion\n\n%% Section 2: Python range\n\\section{Python — Rewriting a Loop}{12}\n\\text{Below is a loop written with a literal list. Rewrite it using range() to produce identical output.}\n\n\\question{Rewrite the loop below using range() so it prints the same values (5, 10, 15, 20, 25, 30).}\n  \\responsemode{answer}\n  \\python\nfor value in [5, 10, 15, 20, 25, 30]:\n    print(value, end=\" \")\n\n# Rewrite using range() below:\n  \\endpython\n  \\sampleresponses{for value in range(5, 31, 5):\n    print(value, end=\" \")}\n  \\feedbackprompt{Require range() generating 5,10,15,20,25,30. Stop must be ≥31. Step must be 5. Nudge if stop is 30 (misses 30).}\n\\endquestion\n\n%% Section 3: Turtle\n\\section{Python Turtle — Filled Square}{12}\n\n\\question{Use a for loop to draw a filled square with side length 100. Fill it with any color you choose.}\n  \\responsemode{answer}\n  \\pythonturtle{400x300}\nimport turtle\nt = turtle.Turtle()\nt.speed(3)\n# Your code here:\n  \\endpythonturtle\n  \\sampleresponses{t.fillcolor(\"blue\")\nt.begin_fill()\nfor _ in range(4):\n    t.forward(100)\n    t.left(90)\nt.end_fill()}\n  \\feedbackprompt{Require: (1) for loop runs 4 times, (2) forward(100) and left(90) inside loop, (3) begin_fill() before and end_fill() after. Accept any fill color. Nudge if fill calls missing or misplaced.}\n\\endquestion\n\n%% Section 4: C++\n\\section{C++ — Odd Numbers}{12}\n\n\\question{Write a C++ for loop that prints the odd numbers from 1 through 19, each on its own line, using cout.}\n  \\responsemode{answer}\n  \\cpp\n#include <iostream>\nusing namespace std;\nint main() {\n    // Write your for loop here:\n    return 0;\n}\n  \\endcpp\n  \\sampleresponses{for (int i = 1; i <= 19; i += 2) {\n    cout << i << endl;\n}}\n  \\feedbackprompt{Require a for loop starting at 1, incrementing by 2, stopping ≤19, printing each value with cout. Accept endl or \"\\n\". Nudge if incrementing by 1 (includes evens) or bounds miss 19.}\n\\endquestion\n\n%% Section 5: Trace Table\n\\section{Trace Table — Accumulator}{10}\n\\text{Trace through the execution step by step. Fill in the value of each variable after each iteration.}\n\n\\question{Complete the trace table for:\ntotal = 0\nfor number in range(1, 5):\n    total = total + number}\n  \\responsemode{answer}\n  \\table{Execution Trace}\n    \\row Iteration & number & total (before) & total (after)\n    \\row 1 & \\tresponse & \\tresponse & \\tresponse\n    \\row 2 & \\tresponse & \\tresponse & \\tresponse\n    \\row 3 & \\tresponse & \\tresponse & \\tresponse\n    \\row 4 & \\tresponse & \\tresponse & \\tresponse\n  \\endtable\n  \\sampleresponses{Iteration 1: number=1, total before=0, total after=1\nIteration 2: number=2, total before=1, total after=3\nIteration 3: number=3, total before=3, total after=6\nIteration 4: number=4, total before=6, total after=10}\n  \\feedbackprompt{Accept if number takes values 1,2,3,4 and total accumulates correctly as 0→1→3→6→10. Nudge if off-by-one in range (e.g., including 5 or starting at 0).}\n\\endquestion\n\n%% Section 6: Reflection\n\\section{Reflection}{4}\n\n\\question{Which question type gave your group the most productive discussion? Why?}\n  \\responsemode{answer}\n  \\multiplechoice{}\n    \\choice{Text explanation — forced us to articulate the concept}\n    \\choice{Python code — debugging range() arguments caused real discussion}\n    \\choice{Turtle — visible output made errors immediately obvious}\n    \\choice{C++ — syntax differences from Python sparked comparison}\n    \\choice{Trace table — stepping through by hand revealed what we didn't know}\n  \\endmultiplechoice\n  \\feedbackprompt{Accept any choice; ask the group to give one specific reason from their discussion that supports their choice.}\n\\endquestion"
    }
  ]
}