Unit 01 · lesson

Make the Computer Obey

Core path: 35 minutes

Can you produce exact behavior, change it on purpose, and recover when you break it?

This is the first week where the course stops talking about programming long enough for you to prove the idea yourself.

You are going to build a tiny program, change it, break it twice, and recover it twice.

Keep every version. The evidence matters in Lesson 5.

Build a baseline that you can prove works

Create hello.py with enough print() instructions to produce exactly this output:

SYSTEM START
Checking systems...
Python detected.
Developer detected.
SYSTEM READY

Do not copy five print() calls blindly and move on. Count the required output lines first. Then compare your source against the result after the program runs.

Use the browser runtime as a quick baseline check before or after you build the same file in your development environment:

hello.py
OutputRun with button or Ctrl/Cmd+Enter
Run the code to see output.
Ready to edit. Press Run when you want evidence.

Treat this as a known-good baseline. Change exactly one message, run again, and identify the one observed effect caused by that source change.

Your baseline is complete when:

  • the file is named hello.py;
  • all five lines appear;
  • capitalization and punctuation match;
  • no extra output appears; and
  • you can explain which source line produced each output line.

Save a copy of the working source before you experiment further.

A working baseline is useful because it gives you something to compare against. Without one, every later change becomes guesswork about whether the program was already broken.

Change the behavior without changing the mechanism

Now redesign the messages. For example:

ROBOTNIX TERMINAL
Loading Python...
Environment ready.
Hello, developer.
Awaiting instructions...

You may write your own five-line version instead.

Run it again.

The interpreter did not change. The command did not change. The program's behavior changed because the source text changed.

Write down one exact example in this form:

SOURCE CHANGE:
"SYSTEM START" → "ROBOTNIX TERMINAL"

OBSERVED EFFECT:
The first output line changed to ROBOTNIX TERMINAL.

That sounds almost too obvious to record. Record it anyway. Cause and effect is the habit.

Break it on purpose

Now create a broken version by removing a closing parenthesis:

print("ROBOTNIX TERMINAL"

Run the file.

Do not repair it yet.

Capture or copy the error evidence. Record:

  • the exact source change;
  • what Python reported;
  • the file or line information you can identify;
  • what you think caused the failure; and
  • the smallest repair you can make.

Repair only that problem. Run the file again and confirm the working output returns.

Break it a different way

Now create another failure:

pritn("ROBOTNIX TERMINAL")

Run it.

Again: read first, edit second.

Compare this report with the missing-parenthesis failure. The two mistakes do not fail for the same reason, and Python does not describe them in exactly the same way.

You do not need to memorize the formal categories yet. Week 7 will take debugging much deeper. Right now, the useful observation is simpler:

Different defects leave different evidence.

Fix the typo and verify the working program one more time.

One last prediction trap

Before running this code, write down all three outputs:

print("10 + 5")
print(10 + 5)
print("10" + "5")

Then test the prediction:

prediction.py
OutputRun with button or Ctrl/Cmd+Enter
Run the code to see output.
Ready to edit. Press Run when you want evidence.

Predict all three lines before running. Then explain each result using the source representation, not just the output you observed.

Expected behavior:

10 + 5
15
105

The quotation marks change what Python is being asked to do.

"10 + 5" is one piece of text.

10 + 5 is a numeric expression.

"10" + "5" joins two pieces of text.

Week 3 will give those different kinds of data proper names and show you how Python keeps track of them. For now, notice the larger point: small syntax changes can change the meaning of an instruction.

One clean recovery record

A useful evidence record looks like this:

WORKING SOURCE
print("SYSTEM READY")

CONTROLLED CHANGE
Removed the closing parenthesis.

OBSERVED EVIDENCE
Python reported invalid syntax near the print statement.

HYPOTHESIS
The function call is incomplete.

REPAIR
Restored the closing parenthesis.

VERIFICATION
Ran python hello.py again and SYSTEM READY printed.

Notice what is missing: "I clicked around until it worked."

You should finish this lesson with:

  • one final working hello.py;
  • one saved or copied missing-parenthesis version and its error evidence;
  • one saved or copied misspelled-name version and its error evidence; and
  • your three predictions from the quotation-mark challenge.

Do not throw those away. Lesson 5 starts with them.

Vocabulary lab

Flip the idea, not just the card

Explain the term before you reveal the back. Then compare your explanation with the definition, example, and warning.

1 / 5
Read all terms without animation
Baseline
A known working version used as a comparison point before making changes. Example: The five-line hello.py that produces the required output before experiments begin. Do not confuse it with: An untested draft whose behavior is still unknown.
Controlled Change
One deliberate modification made so its effect can be observed clearly. Example: Removing one closing parenthesis and running the same program again. Do not confuse it with: Changing several unrelated lines at once.
Evidence
Observable information used to support a claim about what the program did. Example: Terminal output, an error message, a line number, or the saved source file. Do not confuse it with: A guess about what probably happened.
Verification
Checking that a repair or change actually produces the required behavior. Example: Running hello.py again after restoring the parenthesis and confirming the expected output. Do not confuse it with: Assuming the fix worked because the source looks right.
Prediction
A result stated before execution so it can be compared with actual behavior. Example: Predicting that print(10 + 5) will output 15 before running it. Do not confuse it with: Explaining the output only after seeing it.