Reading and Running Code

  1. Tracing Program State by Hand

    A trace records the values that change as a program runs. Follow a few assignments to find the first step where the actual result differs from your expectation.

    Undergraduate
  2. Expressions and Statements

    A readable program makes it clear which constructs compute values and which steps change the state or direction of the computation.

    Undergraduate
  3. Names, Objects, and Bindings

    Understand what assignment changes, when two names share an object, and why update order matters in everyday programming.

    Undergraduate
  4. Source Code, Programs, and Running Processes

    A saved program can produce several independent executions, each with its own input, state, output, and lifetime.

    Undergraduate
  5. Syntax Errors and Runtime Failures

    Locate a failure by asking whether the language can parse the source and whether evaluation reaches a valid operation.

    Undergraduate
  6. Reading a Python Traceback

    Use the exception type, reported line, and chain of calls to find the inputs behind a failed operation.

    Undergraduate
  7. Script and Module Entry Points

    Separate definitions from the action that starts a program so that importing a tool for testing does not accidentally run it.

    Undergraduate
  8. Return Values and Observable Side Effects

    Identify the result delivered to the caller and the changes a call makes to its surroundings.

    Undergraduate
  9. Reading Operator Precedence

    Group an expression according to the language's rules, then use parentheses to make the intended calculation visible to a reader.

    Undergraduate
  10. Evaluation Order and Function Arguments

    Evaluation order matters when a function argument performs work, shares state, or may raise an exception before the call.

    Undergraduate
  11. Naming Variables with Units and Meaning

    Names carry information about units, expected state, and domain meaning that the underlying numeric or text value cannot express alone.

    Undergraduate
  12. Naming Intermediate Results

    An intermediate binding can reveal the source, unit, or invariant of a value and make errors easier to locate.

    Undergraduate
  13. Comments That Explain a Decision

    A useful comment records a domain rule or a reason a reader could not recover by following the control flow alone.

    Undergraduate
  14. Reading Sample Inputs and Outputs

    A sample reveals how a program represents data, chooses its boundaries, and formats its result. Interpret it before generalizing.

    Undergraduate
  15. Reading and Writing Pseudocode

    Pseudocode describes a procedure in terms of observable steps. Explicit indexing, mutation, and stopping rules make it precise enough to implement.

    Undergraduate
  16. Choosing Testable Program Inputs

    An example becomes more useful when changing one input can distinguish between two plausible implementations.

    Undergraduate
  17. Input, State, and Output in a Program

    Distinguish information supplied to a run from the state retained during it and the observations it emits along the way.

    Undergraduate
  18. Logical Blocks and Indentation

    Indentation represents control structure in Python. A one-line change in indentation can decide whether work happens once or repeatedly.

    Undergraduate
  19. Local and Module-Level Name Lookup

    Python resolves names using the function's lexical context. An assignment can alter which binding an earlier read in the same function uses.

    Undergraduate
  20. Reproducing a Program Run

    Record the parts of the environment that supply input even when they are absent from the command line.

    Undergraduate
  21. Exit Status and Command Output

    Programs can report a successful run separately from whatever they write to an output stream. Callers use the exit status to decide whether to continue.

    Undergraduate
  22. Displaying Values as Text

    A display representation can hide distinctions that matter during troubleshooting, including whitespace, types, and precision.

    Undergraduate
  23. Imports and Bound Names

    An import can bind a module object or a name drawn from it. That choice affects what another module observes after a subsequent assignment.

    Undergraduate
  24. Command-Line Arguments Start as Text

    Each command-line argument reaches an ordinary Python program as a string. A command's argument parser supplies types and reports invalid values.

    Undergraduate
  25. Literals, Calculated Values, and Domain Constants

    A literal supplies a concrete value in the source. A well-named constant records a policy, unit conversion, or invariant shared across calculations.

    Undergraduate
  26. Small Experiments in the Python Interpreter

    An interactive interpreter helps isolate an expression or check a language rule. Keep enough context to replay the experiment in a fresh session.

    Undergraduate
  27. Reading a Program as a Chain of Transformations

    A program that changes data through several representations is easier to inspect when each stage has a named input and output.

    Undergraduate
  28. Reading Equality Checks and Updates

    An assignment changes a binding. An equality expression produces a truth value that can guide a later decision.

    Undergraduate
  29. Returning from a Function Call

    When a function returns, its caller resumes at a pending expression or statement and can use the delivered value.

    Undergraduate
  30. A Worked Python Program from Input to Result

    Calculate the cost of three orders from compact text records and use the result to practice tracking intermediate state and validation.

    Undergraduate