Week 9 Coding Lab: Lists in the Community Garden
Part 1 — The Big Picture
This week you learned that a list keeps many values in order under one name, that you read it by index from 0 or from the end, that a slice is a new list, that methods change a list in place and most of them hand back None, that a second name for a list is not a second list, and that a loop must never remove items from the list it is walking. In this lab you put those ideas to work in a community garden. You predict what six short list programs print, run them, and study every gap between your prediction and the run. Then you read three broken programs, fix each with the smallest change that works, write a short program of your own, and check a chatbot's answers to the same questions by running the code, because a chatbot predicts likely text and does not run your program.
Time budget: Plan for about 90 minutes.
Part 2 — The Task
Guiding question: In the garden's harvest log, which of these six predictions about lists will you get wrong, and how will each run show you exactly what a slice holds, what a method hands back, and when two names share one list?
Workshop data: A community garden's harvest log: six short list programs and three broken ones
Source: Six short Python programs and three broken programs about an illustrative community garden's harvest log, bed list, and frost readings, written for this lab and printed in full in Part 4; the garden and its numbers are invented and describe no real group or person.
- Rows: 9 short programs in all: 6 programs to trace in the first table and 3 broken programs in the second table
- Language: Python 3, run in a free browser runner; no file to download and nothing to install
- Context: an illustrative community garden with a five-day harvest list, a list of planting beds, and four frost readings
Part 3 — Materials & Procedure
Tools and materials
- A free browser-based Python runner (an online editor that runs Python 3 with no account and nothing to install), Python Tutor at pythontutor.com for step-by-step visualization, the official Python documentation at docs.python.org, and one approved chatbot used as a pair-programmer whose code the student runs before trusting
Ways of working
- write-run-and-verify
- trace-and-predict-output
- find-and-fix-the-bug
Procedure
- Open a free browser Python runner in one tab and Python Tutor at pythontutor.com in another. In the runner, delete any sample code so the editor is blank. Tool: A free browser-based Python runner (an online editor that runs Python 3 with no account and nothing to install), Python Tutor at pythontutor.com for step-by-step visualization, the official Python documentation at docs.python.org, and one approved chatbot used as a pair-programmer whose code the student runs before trusting. Check: An empty editor with a Run button and a separate output panel.
- In the first table in Part 4, write your prediction for each of the six programs before you run anything. Then type each program into the runner exactly as printed, one statement per line, press Run, and copy the output into the Actual output column. Tool: A free browser-based Python runner (an online editor that runs Python 3 with no account and nothing to install), Python Tutor at pythontutor.com for step-by-step visualization, the official Python documentation at docs.python.org, and one approved chatbot used as a pair-programmer whose code the student runs before trusting. Check: Six actual outputs, one per row, each copied character for character from the output panel; at least one is likely to differ from your prediction.
- Type each broken program from the second table into the runner, with four spaces in front of each loop body line and eight in front of each line inside an if inside the loop, and press Run. For an error, scroll to the bottom of the error message and copy the error type from its last line. For a program that runs, compare what it printed with what its description says it should print. Tool: A free browser-based Python runner (an online editor that runs Python 3 with no account and nothing to install), Python Tutor at pythontutor.com for step-by-step visualization, the official Python documentation at docs.python.org, and one approved chatbot used as a pair-programmer whose code the student runs before trusting. Check: For each broken program, either a printed list or number that does not match its description, or an error type copied from the last line.
- Fix each broken program with the smallest change that makes it do what its description in Part 4 says, run the fixed version, and record the new output. Tool: A free browser-based Python runner (an online editor that runs Python 3 with no account and nothing to install), Python Tutor at pythontutor.com for step-by-step visualization, the official Python documentation at docs.python.org, and one approved chatbot used as a pair-programmer whose code the student runs before trusting. Check: Each fixed program runs without an error and prints the warmest reading, the plots with every empty marker gone, or the last harvest that its description asks for.
- Paste the crates program from row 5 of the first table into Python Tutor, click the button to visualize it, and step forward one line at a time. Watch how many list boxes appear and where the arrows from crates and extra point after the second line. Tool: A free browser-based Python runner (an online editor that runs Python 3 with no account and nothing to install), Python Tutor at pythontutor.com for step-by-step visualization, the official Python documentation at docs.python.org, and one approved chatbot used as a pair-programmer whose code the student runs before trusting. Check: One list box with two arrows pointing at it, and the append showing up through both names.
- Write your own short program: store the five harvest weights 8, 3, 11, 6, and 7 in a list, walk it with a for loop to print the total, then print the total divided by the length, then walk it again to print the biggest weight, starting the biggest-so-far at the first item. Predict each output, run it, and fill in the third table. Tool: A free browser-based Python runner (an online editor that runs Python 3 with no account and nothing to install), Python Tutor at pythontutor.com for step-by-step visualization, the official Python documentation at docs.python.org, and one approved chatbot used as a pair-programmer whose code the student runs before trusting. Check: A short program that runs without an error and prints three lines you can compare with your predictions.
- Open your approved chatbot, paste the critique prompt from Part 6 as one message, then check each of its claims by running the code it talks about. If you are using the equivalent route, mark up the printed flawed analysis in the same way. Tool: A free browser-based Python runner (an online editor that runs Python 3 with no account and nothing to install), Python Tutor at pythontutor.com for step-by-step visualization, the official Python documentation at docs.python.org, and one approved chatbot used as a pair-programmer whose code the student runs before trusting. Check: The fourth table lists each chatbot claim, what your run showed, and a correction wherever the two disagree.
Fallback route
When to use it: Use this route if your browser Python runner will not open or will not run code.
Run every program in Python Tutor instead, which also runs Python 3 in the browser: paste each program, click the button to visualize it, and step to the end to read its output or its error. Complete every table, analysis question, and the critique step, and submit the same items for equal credit.
This route earns the same credit as the primary route.
Part 4 — The Scaffold
Predict first and run second, so the gap between the two columns is your own evidence of what a slice holds, what a method hands back, and which names share a list.
| Program | Your prediction | Actual output from the run | Same or different? |
|---|---|---|---|
harvest = [8, 3, 11, 6, 7], then print(harvest[1:4]) |
|||
harvest = [8, 3, 11, 6, 7], then print(harvest[-2], len(harvest)) |
|||
beds = ["kale", "beans"], then print(beds.append("leeks")) |
|||
beds = ["kale", "beans", "leeks"], then beds.insert(1, "chard"), then print(beds) |
|||
crates = [8, 3, 11], then extra = crates, then extra.append(5), then print(crates) |
|||
w = [2, 9, 4], then print(sorted(w), w) |
Read each broken program from its run before you change a single character.
| Broken program and what it should do | What printed, or the error type on the last line | Your one-change fix | Output after the fix |
|---|---|---|---|
Bug 1, should print the warmest of four frost readings: lows = [-2, -5, -1, -4], then biggest = 0, then for t in lows: with if t > biggest: biggest = t inside, then print(biggest) |
|||
Bug 2, should remove every empty marker from the plot list: plots = ["", "", "peas", "", "corn"], then for p in plots: with if p == "": plots.remove("") inside, then print(plots) |
|||
Bug 3, should print the last harvest weight: harvest = [8, 3, 11, 6, 7], then print(harvest[5]) |
Write your own small program, then let the run confirm or correct what you expected it to print.
| Line you wrote | Output you expected | Output of the run |
|---|---|---|
| Line 1 | ||
| Line 2 | ||
| Line 3 | ||
| Line 4 |
Check every chatbot claim against a run so the run, not the chatbot, has the last word.
| Chatbot claim, quoted | What your run showed | Correct as stated, or your correction |
|---|---|---|
Part 5 — Analysis Questions
- Which of your six predictions in the first table differed from the run? For each one, write the step-by-step trace that reaches the actual output and name the rule that explains the gap, such as a slice leaving out its stop, a method handing back None, or two names sharing one list.
- For row 5 of the first table, how many list boxes did Python Tutor draw, and where did the arrows from crates and extra point? Use what you saw in step 5 to explain why crates changed when only extra was appended to.
- Bug 1 and Bug 2 run without any error message but print the wrong thing. Explain why that makes each a logic error, and explain why Bug 3 is a runtime error instead.
- Choose one: (a) describe how you would decide whether to trust a chatbot's claim that a line of code makes a copy of a list, using one claim from your critique as the example; or (b) describe how predicting before running changed what you noticed about what a list method hands back in this lab, using one row of your first table as the example.
- Every list in this lab was short and had at least one item. Name one thing these runs could not tell you about a program that must handle any harvest log, such as an empty one, and say how you would check it by running more cases.
Part 6 — AI-Critique Moment
Choose one equal-credit critique route. Route A: ask an approved AI tool to critique your completed work, then check its response against your own evidence. Route B is the no-AI equivalent printed below.
Approved tools: Claude, Gemini, ChatGPT, Grok, Microsoft Copilot.
Prompt to paste:
I'm doing a beginner Python lab about a community garden's harvest log, written for a class activity. Please do seven things, and keep each answer short. First, predict exactly what each of these programs prints: harvest = [8, 3, 11, 6, 7] followed by print(harvest[1:4]); and crates = [8, 3, 11], then extra = crates, then extra.append(5), then print(crates), and explain in one sentence why crates prints what it does. Second, write one line that prints the last item of harvest by its position. Third, does beds.sort() hand back the sorted list? Show what print(beds.sort()) prints when beds = ["kale", "beans", "leeks"]. Fourth, write two lines that save a backup of beds = ["kale", "beans"] so that removing "kale" from beds later leaves the backup unchanged, and say whether your version works. Fifth, this program should remove every empty marker "" from a list of garden plots but leaves one behind; fix it: plots = ["", "", "peas", "", "corn"], then for p in plots: with if p == "": plots.remove("") inside, then print(plots). Sixth, this program should print the warmest of four frost readings but prints 0; fix it: lows = [-2, -5, -1, -4], then biggest = 0, then a loop that sets biggest = t whenever t > biggest, then print(biggest). Seventh, will that biggest-so-far loop work on every list of readings a garden might log?
Test the response for these likely failures:
- Chatbots often predict that
print(harvest[1:4])prints [3, 11, 6, 7], treating the stop index 4 as part of the slice. - A chatbot may correctly say the alias program prints [8, 3, 11, 5] while explaining that
extra = cratesmakes a separate copy, which would leave crates unchanged. - Asked for the last item, a chatbot may write
print(harvest[5])orprint(harvest[len(harvest)]), treating the length as the last index. - A chatbot may say
beds.sort()hands back the sorted list, soprint(beds.sort())shows the crops in order. - A chatbot may offer
backup = bedsas the backup line and call it working without running it. - A chatbot may fix the plots loop by calling
plots.pop()for each empty marker, which runs without an error. - A chatbot may say the biggest-so-far loop works on every list once it starts from the first reading.
Write 2-3 sentences that name one thing the chatbot got right and at least one claim you corrected, and for each correction give the output or error type your own run showed.
Equivalent route (no AI required)
No AI account is required for this lab. Instead of the chatbot, critique this flawed analysis, printed here in full: “print(harvest[1:4]) prints [3, 11, 6, 7], because the slice runs up to index 4. The alias program prints [8, 3, 11, 5], because extra = crates makes a separate copy of the crates. To print the last harvest, write print(harvest[5]), since the list holds 5 weights. print(beds.sort()) prints the crops in alphabetical order. To keep a backup of the beds, write backup = beds; this version is working. To clear the empty markers, call plots.pop() for each empty one; the program then runs without an error. Once the biggest-so-far starts at the first reading, the loop works on every list a garden could log.” Mark it up: quote each flawed sentence, run the code it describes in your browser Python runner, and write the corrected claim beside it with the run's output or error type as evidence. This route assesses the same objectives as the chatbot critique, namely reading and slicing a list, predicting what a list method hands back, telling an alias from a copy, avoiding the mutate-while-iterating trap, and checking every claim about code by running it (Objective 6 and Objective 4), and it takes comparable effort, about 20 minutes of the lab. It is scored by the same rubric for the same credit, and its marked-up analysis replaces the chatbot report and share link in your submission. You do not need to say which route you chose.
Part 7 — What to Submit
- All four completed scaffold tables
- Written answers to all five analysis questions
- Your harvest program with its run output
- The chatbot critique report with its share link, or the equivalent route's marked-up flawed analysis
Deliverable:
A short Coding Lab report on an illustrative community garden: four completed tables (six predictions beside their runs, three broken programs read and fixed, your own harvest program, and the checked chatbot claims), written answers to five analysis questions, and a critique of a chatbot's answers to the same questions, or, on the equivalent route, a marked-up correction of the printed flawed analysis. Submit in any accessible file type or as a link; a recorded response may be submitted as audio or video with a transcript, or as text. Choose a written, recorded, or visual form for your answers, such as screen captures of your runs with a short note for each; every form is graded by the same rubric.
Rubric
The rubric below shows how each submitted part is evaluated; bands are full, partial, or none.
| Criterion | Full | Partial | None |
|---|---|---|---|
| Predicting and running the six programs | All six predictions are recorded before the runs, and all six actual outputs match what the programs print, copied character for character. | The table is mostly complete, but an actual output is missing or miscopied, or predictions appear to have been filled in after running. | No predictions or runs are recorded, or the outputs are invented rather than run. |
| Explaining the gaps between prediction and run | Every prediction that differed from its run is traced step by step to the actual output, with the governing rule named, such as a slice leaving out its stop, a method handing back None, or two names sharing one list. | The gaps are listed, but a trace is missing or the rule behind a gap is not named. | No gap is explained, or the response blames the runner instead of the rule. |
| Finding and fixing the three bugs | Each bug is read correctly from its run: what printed or the error type, a one-change fix, and the fixed program's output, with Bugs 1 and 2 identified as logic errors and Bug 2's fix keeping both crops. | Two of the three bugs are read and fixed correctly, or all three are fixed but an error type or the run evidence is missing. | The bugs are not attempted, or errors are named without running the programs. |
| Writing, running, and verifying a program | The harvest program runs without an error, stores the five weights in a list, walks it for a total, an average, and a biggest-so-far that starts at the first item, and its expected and actual outputs are recorded side by side. | The program runs but misses one requirement, such as a biggest-so-far that starts at 0, or the expected or actual output is not recorded. | No program is submitted, or it was not run. |
| Critiquing the AI analysis or the printed flawed analysis | The chatbot's answers, or on the equivalent route the printed flawed analysis, are quoted and at least two claims are corrected with evidence from the student's own runs. | The critique names errors but corrects only one, or corrects without run evidence, on either route. | No critique is submitted on either route, or chatbot or flawed text is pasted without any checking. |
| Reflection and limitation | The chosen reflection option is answered with a specific example from this lab, and the limitation answer names something these runs cannot show and a sensible way to check it. | The reflection or the limitation is general, without an example from this lab or a way to check it. | The reflection and limitation questions are not answered. |
Quality Gate
- Every prediction in the first table was written before its program was run.
- Every actual output and error type is copied from your own run, never from memory or a chatbot.
- Each error is named by its type from the last line of the error message, not by the wording after the colon.
- Each fix changes as little as possible and its fixed program was run.
- No output, count, or claim is invented anywhere in the submission.
- The critique quotes the chatbot or the flawed analysis and corrects at least two claims with evidence from your runs.
Built with The Course Maker · samples.thecoursemaker.com