Programming in Python · Lesson 2

Programming Tools

Editors, interpreters, environments, and debugging tools that support writing and running Python programs.

  • python
  • programming-tools
  • interpreter
  • debugging

Lesson purpose

Programming tools provide the workspace between an idea and a running Python program. Students should be able to distinguish source code, an editor, the interpreter, an interactive shell, and an integrated development environment (IDE).

Learning objectives

  • Identify the roles of an editor, interpreter, shell, IDE, and file system.
  • Create, save, run, and revise a Python source file.
  • Distinguish syntax, runtime, and logic errors.
  • Use readable filenames, indentation, comments, and a repeatable test cycle.

1. Source code and editors

Source code is the human-readable text that expresses a program. A plain-text code editor adds helpful features such as syntax coloring, indentation, search, and line numbers without changing the meaning of the code. Save Python files with a .py extension and a descriptive name.

print("Hello, Python!")

The editor is not the program’s result; it is where the instructions are written and maintained. Save before running so the executed file matches what students see.

2. Interpreter and interactive shell

Python is commonly used through an interpreter that reads source code and executes it. The interactive shell (REPL) is useful for quick experiments: enter an expression, inspect the result, and try the next idea. A saved script is better for a complete, repeatable program.

>>> 2 + 3
5
>>> print("test")
test

Use the shell to test a small expression or library behavior; use a .py file when the solution needs to be rerun, shared, or graded.

3. IDEs and project organization

An IDE combines an editor, run controls, an interpreter configuration, a file browser, and debugging tools. Students should know which interpreter/version runs the file and where the file is saved. Keep related files in one project folder, use meaningful names, and avoid storing credentials or private data in source code.

4. Running and testing

The basic cycle is: write a small change → save → run → inspect output → test another input → revise. Test normal cases, boundary cases, and invalid input. Read the traceback from the bottom upward: the final line usually identifies the exception and the location.

5. Error categories

  • Syntax error: Python cannot parse the instructions, often because of a missing colon, quote, or parenthesis.
  • Runtime error: the program starts but fails while running, such as dividing by zero or using a missing file.
  • Logic error: the program runs but computes or displays the wrong result.
# Syntax error: the closing parenthesis is missing.
print("Ready"
# Logic error: the intended total should add both values.
first = 4
second = 7
total = first - second
print(total)

Classroom application

Have students create hello.py, run it from the IDE and shell, then intentionally introduce one syntax error and one logic error. Students should identify the category, quote the evidence, and make the smallest correction.

Common misconceptions

  • The interpreter executes Python; the editor only stores and displays source code.
  • A program that runs successfully can still contain a logic error.
  • Saving and running are separate actions; an unsaved edit may not be what executes.
  • Error messages are evidence for debugging, not a substitute for testing.

Lesson summary

A reliable Python workflow combines a readable editor, the correct interpreter, organized files, small tests, and deliberate debugging. Tool fluency lets students spend more time reasoning about the problem.