Chapter 1

Running Code

The first Python habit: write a small program, run it, read what happens, edit one thing, and run again.

Subject
Python
Lessons
6 lessons
Practice
11 checks
Review
3 pages

What this chapter does

Before Python can help with arrays, plots, or models, the reader needs the basic run loop. This chapter makes code, output, errors, scripts, and interactive sessions concrete.

Lessons

Read these in order.

The chapter opening gives the main idea. Move through these lessons next; each page reuses ideas from the pages before it.

  1. 01
    What Python Runs

    Code as exact instructions, output as evidence, and expressions as values.

  2. 02
    Installing and Checking Python

    How to check for a Python 3 runtime before installing anything else.

  3. 03
    Scripts and the Terminal

    Running a saved Python file from the terminal and reading its output.

  4. 04
    Interactive Sessions

    Using the Python prompt for small checks while keeping longer work in scripts.

  5. 05
    Reading Output and Errors

    Output as evidence and errors as reports about where Python got stuck.

  6. 06
    Editing and Rerunning

    Changing one thing, rerunning, and comparing the result with expectation.

  1. Conclusion

    What the first running-code loop prepares before names, values, and types.

  2. Review

    A compact review of commands, script habits, errors, and controlled edits.

  3. Exercises

    Chapter-level practice for output prediction, version checks, errors, prompts, and controlled edits.

You are ready when

  • Run a small Python script.
  • Tell code apart from output.
  • Use an interactive session for tiny checks.
  • Read simple errors as debugging information.
  • Edit one line, rerun, and explain the changed output.

Where this leads

  • Names, Values, and Types
  • Branches and Loops
  • Functions

Chapter progress