← Back to the Introduction to Computer Science outline The Course Maker
← Introduction to Computer Science outline
Week 1 · Assignment: Traditional alternative (no AI)

Week 1 — Predict, Run, Explain: Your First Python Traces — Traditional alternative (no AI)

Introduction to Computer Science Free sample edition
Traditional alternative (no AI), unpublished. In the course this is a separate assignment that ships unpublished beside the adaptive assignment: same objective, no AI. An instructor who prefers it publishes it and unpublishes or deletes the adaptive one, as the note at its top says.

Instructors: publish this instead of the adaptive version if you prefer, and unpublish or delete the adaptive one.

Assignment 1 of the term — predict what short Python lines print, run them to check, read two error messages from their last lines, and explain it all to someone who has never programmed.

This week you wrote your first Python lines, learned to predict what a line prints before you run it, and read error messages from their last line. In this assignment you trace four short programs, run each one to check your prediction, read two error messages, and explain the result to someone who has never programmed. This week's lecture tutorial, quiz, discussion, and Coding Lab practise the same ideas from other angles.

The task

A relative watched you run your first Python line and said, "Your computer got the math wrong: 2 plus 3 is 5, and 5 times 4 is 20, but it printed 14." Your job is to check that claim the way a programmer would: predict each line before you run it, run it in a free browser Python runner, and explain what Python actually did. All four programs are illustrative.

Work these four problems. For each one, write your prediction first, then run the line and write the actual output beside your prediction:

  1. What does the one-line Python program print(2 + 3 * 4) print when it runs?
  2. What does the one-line Python program print((2 + 3) * 4) print when it runs?
  3. A study room has two tables with 4 chairs each plus 3 extra chairs, and the line print(3 + 2 * 4) counts them. What does it print?
  4. What does the one-line Python program print(10 / 2) print when it runs?

Beside each answer, add one brief interpretation:

  • Problem 1: name operator precedence as the reason for the output, and explain why 20 is the tempting wrong prediction.
  • Problem 2: say what the parentheses changed, and compare this output with your Problem 1 output.
  • Problem 3: say which line, print(3 + 2 * 4) or print((3 + 2) * 4), matches the real chair count, and explain why both lines run without an error although only one of them fits the room.
  • Problem 4: explain the decimal point in the output in one sentence (Week 2 explains it fully). Then run these two broken programs and, for each, read the last line of the error message, name the error type, and say whether line 1 printed before it stopped:
print("Reading log: day 1")
Print("Goal: 300 pages")
print("Reading log: day 1")
print("Goal: 300 pages"

Explain it to a non-programmer

Write a 3–5 sentence message to your relative that explains, in everyday words, why the computer printed 14 and did not get the math wrong. Use the idea that the computer does exactly what you wrote, not what you meant, say how parentheses would have produced 20, and name one limit or caveat, such as the fact that the rule only tells you what Python does, not what you intended. Explain any technical term in everyday words. More than one good message is possible.

For a different, ungraded example, imagine a coworker who typed 8 − 2 × 3 into a phone calculator, expected 18, and got 2. Model message: "The calculator did not make a mistake. It follows a fixed rule: multiply before you subtract, so it worked out 2 × 3 = 6 first and then 8 − 6 = 2. If you meant to subtract first, put parentheses around 8 − 2. The rule tells you what the calculator will do; it cannot guess what you meant, so check the grouping before you trust a total."

Use that pattern for your relative's question, with your own wording and evidence.

Show your traces. A reader should be able to follow every prediction step by step and see the actual output of your run beside it, without guessing which values or order of operations you used.

Deliverables

Submit a single report containing:

  • the four answers, each with your prediction, the step-by-step trace, the actual output of your run, and the brief interpretation the task names for that problem;
  • the two error readings, each naming the error type from the last line of the error message and saying whether line 1 printed; and
  • your message to your relative, explaining why the computer printed 14, how parentheses would have produced 20, and one limit.

Keep it to roughly one page. Clear and correct beats long.

Choose how you show it. Present your report as written text, or as a recorded audio or video explanation of about three minutes with a transcript, or as labelled screen captures of your runs with a short note for each. Every form is graded by the same scoring criteria. 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.

How you'll be graded

The full analytic rubric is attached to this assignment in Canvas.

Academic integrity and AI use

This version is designed to be completed without AI: make the predictions, run the code, and write the interpretations and the message yourself, without any AI tool. You may use a free browser Python runner, Python Tutor, and the official Python documentation. Submitting AI-generated work as your own, or copying another student's work, is an integrity violation under the course policy.

Built with The Course Maker · samples.thecoursemaker.com