← Back to the Introduction to Computer Science outline The Course Maker
← Introduction to Computer Science outline
Week 1 · Coding Lab

Week 1 Coding Lab: Predict, Run, and Fix a Bake-Sale Tally

Introduction to Computer Science Free sample edition

Part 1 — The Big Picture

This week you learned that the computer does exactly what you wrote, not what you meant. In this lab you put that to work the way programmers do every day: you predict what a short program prints, run it, and study any gap between the two. Then you read three broken programs from the last line of each error message, fix each one with the smallest change that works, and write a tiny program of your own. Finally you ask a chatbot the same questions and check every claim it makes 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: Which of these bake-sale predictions will you get wrong, and how will each run and the last line of each error message show you why?

Workshop data: A bake-sale tally: six short programs and three broken ones

Source: Six one-line Python programs and three broken programs about an illustrative campus bake sale, written for this lab and printed in full in Part 4; the muffin and cookie counts are invented and describe no real sale or person.

  • Rows: 9 short programs in all: 6 one-line 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 bake sale's muffin and cookie counts

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

  1. 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.
  2. 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, 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.
  3. Type the first broken program into the runner and press Run. Scroll to the bottom of the error message and copy the error type from its last line. Note whether anything printed first. Repeat for the second broken program, then run the third, which raises no error. 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 second table shows what printed before each error and the type named on each error message's last line; the third program prints a total without any error.
  4. Fix each broken program with the smallest change that makes it do what its comment 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 total or line its description asks for.
  5. Paste the first broken program into Python Tutor, click the button to visualize it, and step forward one line at a time. Watch line 1 run before line 2 stops the program. 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: Python Tutor shows line 1's output appear before the error on line 2, which matches what the runner showed.
  6. Write your own two-line program for the bake-sale sign: line 1 prints the words Bake sale: table 3, and line 2 uses print with two comma-separated arguments to show the label Brownies: and the result of 3 * 8. Predict its 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 two-line program that runs without an error, with your predicted and actual output side by side.
  7. 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 Python really does.

Student scaffold table 1
Program Your prediction Actual output from the run Same or different?
print(6 + 4 * 3)
print((6 + 4) * 3)
print("6" + "4")
print(6 + 4)
print("Muffins:", 12, "left")
print(9 / 3)

Read each broken program from the last line of its error message before you change a single character.

Student scaffold table 2
Broken program and what it should do What printed before any error Error type on the last line, or none Your one-change fix Output after the fix
Bug 1, should print Bake sale and then Muffins: 12. Line 1: print("Bake sale") Line 2: Print("Muffins:", 12)
Bug 2, should print the total of two trays of 6 cookies plus 4 loose cookies: print("Total cookies:", 4 + 2 * 6
Bug 3, should also print that total of 16 but runs and prints something else: print("Total cookies:", (4 + 2) * 6)

Write your own small program, then let the run confirm or correct what you expected it to print.

Student scaffold table 3
Line you wrote Output you expected Output of the run
Line 1
Line 2

Check every chatbot claim against a run so the run, not the chatbot, has the last word.

Student scaffold table 4
Chatbot claim, quoted What your run showed Correct as stated, or your correction

Part 5 — Analysis Questions

  1. 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.
  2. For Bug 1 and Bug 2, what printed before each error, and which error type did each last line name? Explain what that difference tells you about when each program stopped.
  3. Bug 3 runs without any error message but prints the wrong total. Explain why that makes it a logic error rather than a syntax error or a runtime error, and why a fix that only makes a program run is not enough.
  4. Choose one: (a) describe how you would decide whether to trust a chatbot's claim about what a line prints, using one claim from your critique as the example; or (b) describe how predicting before running changed what you noticed in this lab, using one row of your first table as the example.
  5. A run tells you what a program prints, not what its writer meant. Name one thing your runs in this lab could not tell you, and say how you would check it instead.

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 bake-sale tally program, written for a class activity. Please do six things, and keep each answer short. First, predict exactly what each of these one-line programs prints, and explain your reasoning for the first one: print(6 + 4 * 3); print((6 + 4) * 3); print("6" + "4"); print(6 + 4); print("Muffins:", 12, "left"); print(9 / 3). Second, this program is supposed to print a total of 16 cookies, two trays of 6 plus 4 loose cookies, but it will not run. Fix it and show your fixed version: print("Total cookies:", 4 + 2 * 6 Third, this two-line program stops partway. Say what prints and which error type the last line of the error message names, then fix it: print("Bake sale") followed by Print("Muffins:", 12). Fourth, does Python have a built-in function called printline that prints a line of text? Fifth, write plain-English steps that find the larger of two tray counts, and show they work. Sixth, as a stretch question for later in my course, which numbers does range(1, 5) produce?

Test the response for these likely failures:

  • Chatbots often predict that print(6 + 4 * 3) shows 30, adding 6 and 4 first as if Python read left to right.
  • A chatbot may explain that print puts nothing between its arguments, or that it works from left to right, in the same reply that quotes the correct output, so the explanation and the printed result disagree.
  • A chatbot may present a fixed version of the cookie line that still has an unmatched parenthesis, or one with an extra parenthesis, and call it working without running it.
  • A chatbot may fix the cookie line by also adding parentheses around 4 + 2, so the program runs but now prints 36, a total the bake sale never had.
  • A chatbot may describe a printline function as if it were built into Python, or invent options for it.
  • A chatbot's larger-of-two steps often say "if the first is bigger, report the first; if the second is bigger, report the second" and never say what to report when the two counts are equal.
  • Asked the stretch question, a chatbot may say range(1, 5) produces 1, 2, 3, 4, 5, including the stop value.

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(6 + 4 * 3) prints 30, because Python works from left to right. print("Muffins:", 12, "left") prints Muffins:12left, because print adds nothing between its arguments. To fix the cookie line, write print("Total cookies:", (4 + 2) * 6); this version is working and prints the right total. The two-line Print program raises a SyntaxError, so nothing prints. Python's built-in printline function prints a line of text. To find the larger of two tray counts: if the first is bigger, report the first; if the second is bigger, report the second. range(1, 5) produces 1, 2, 3, 4, 5.” 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, flagging the range sentence as a topic that comes later. This route assesses the same objectives as the chatbot critique, namely tracing short programs, reading error messages by type, and checking every claim about code by running it, 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 two-line bake-sale sign 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 bake-sale tally: four completed tables (six predictions beside their runs, three broken programs read and fixed, your own two-line 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.

Workshop evaluation criteria
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 multiplication before addition or strings joining. 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 first, the error type or the absence of one, a one-change fix, and the fixed program's output, with Bug 3 identified as a logic error. Two of the three bugs are read and fixed correctly, or all three are fixed but an error type or the printed-first evidence is missing. The bugs are not attempted, or errors are named without running the programs.
Writing, running, and verifying a program The two-line sign program runs without an error, uses two comma-separated arguments on line 2, and its expected and actual outputs are recorded side by side. The program runs but misses one requirement, 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, with the range claim flagged as coming later. 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 a run 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