0%

Chapter 1

From Working Code to Program Design

Welcome Back and Check Your Readiness

Hi, I’m Erik. I write and maintain this course, along with the rest of Python Land. Welcome back.

You already know enough Python to build complete single-file programs. You can store values, make decisions, repeat work, organize data in collections, write , handle expected errors, and check results with assertions.

This course asks a different question:

How do you keep a program understandable when it grows beyond a few functions and collections?

You will learn several ways to organize growing programs, split a project across , design useful errors, and test public behavior. The goal is not to use every new tool everywhere. The goal is to choose structures that make a program easier to understand and change.

There is no prize for rushing. Design is the part of programming where the same idea has to be met a few times before it settles, so if a lesson does not land the first time, that is the normal shape of learning it rather than a sign you are behind.

The readiness check uses familiar Fundamentals I tools. Remember that print displays a , while sends a value back to the caller.

What stays on Python Land

You will keep working in the browser. Local installation, , , and package managers belong in a later course. Here, your attention stays on programming and design.

That also means the site should work fairly well on a small screen, like your mobile phone. Try it; you can read a lesson or two while waiting for something or someone, and a quick re-read of an earlier lesson is time well spent. The longer editing exercises in this course go better with a real keyboard, so those are worth saving for when you are at a computer.

A short readiness check

These questions sample the skills this course builds on. They are diagnostic, not a trick or an entrance exam.

What does this print?

values = [2, 4, 6]
total = 0

for value in values:
    total += value

print(total)

How do print(result) and return result differ inside a function?

Which expression reads the answer from this dictionary?

question = {
    "prompt": "Two plus two?",
    "answer": "4",
}

Why prefer a specific except ValueError to a bare except when converting input with int()?

If one question felt uncertain, revisit that topic in Fundamentals I or ask Monty for a brief reminder. You do not need perfect recall. You do need enough familiarity to read the small program in the editor.

These lessons revisit the four skills checked above:

Read before you change

The editor contains a function that summarizes attempts. Run it and trace the values through the . You do not need to modify it.

The habit matters: larger-program design begins by understanding the program that already exists.

Task

Run the attempt summary and explain each printed number to yourself.

If you want a closer look, use Step in the exercise editor and watch total, passed, and attempt change through the .