Getting Started with Python · Lesson 2

Install Python or Choose a Notebook Environment

A Python environment is the specific interpreter plus the packages available to it.

ConceptWorked examplePracticeKnowledge check
Textbook walkthrough

Install Python or Choose a Notebook Environment

A Python environment is the specific interpreter plus the packages available to it. Installing Python gives the operating system an interpreter executable; a notebook service adds a browser interface whose kernel points to a particular interpreter. The important question is therefore not only “is Python installed?” but “which Python is executing this code, and which packages belong to it?”

Learning goal: explain why Install Python or Choose a Notebook Environment behaves this way, apply it to a small example, and verify the result independently. Begin by being able to justify this first step: Identify the interpreter with its version and executable path.

Deeper walkthrough

Read Install Python or Choose a Notebook Environment as a mechanism, not a recipe

Treat this as a sequence of observable decisions rather than one opaque command. Stage 1: Identify the interpreter with its version and executable path. Stage 2: Distinguish the operating-system terminal from the Python prompt. Stage 3: Create a virtual environment when a project needs isolated dependencies. Final checkpoint: Install packages into the same environment that executes the code.

Mechanism

Follow the transformation

Identify the interpreter with its version and executable path.

Distinguish the operating-system terminal from the Python prompt.

Create a virtual environment when a project needs isolated dependencies.

Evidence

Know what would convince you

  • Trace a tiny input by hand and compare the runtime result.
  • Inspect type, value/shape and any mutation/side effect explicitly.
Useful distinctionInput: Objects/values supplied to the operation.
Visual demonstration of Install Python or Choose a Notebook Environment
Visual demonstration: use the diagram to trace the main objects and state changes involved in Install Python or Choose a Notebook Environment.
Click a stage to inspect what happens, what changes, and what should be checked before moving on.
Stage 1

Identify the interpreter with its version…

Identify the interpreter with its version and executable path. This is an input-preparation stage for Install Python or Choose a Notebook Environment. Verify the relevant type, shape, units, keys, missingness or assumptions before later steps depend on them.

Input focus: confirm the data/object, units, type, shape and assumptions before the next operation depends on them.
How it works

Trace the mechanism step by step

  1. Identify the interpreter with its version and executable path.
  2. Distinguish the operating-system terminal from the Python prompt.
  3. Create a virtual environment when a project needs isolated dependencies.
  4. In a notebook, verify which kernel/interpreter the notebook is using.
  5. Install packages into the same environment that executes the code.
Worked demonstration

Python environment check

# Step 1 — Import the module so its functions/classes are available to the rest of this example.
import sys
# Step 2 — Display the current value explicitly so the result/state can be inspected during execution.
print(sys.version.split()[0])
# Step 3 — Display the current value explicitly so the result/state can be inspected during execution.
print(sys.executable)
Expected / illustrative result
The output identifies the Python version and the exact interpreter executable used by the running session.
Interpret the result.

For Install Python or Choose a Notebook Environment, trace the specific input through the mechanism above and independently verify one returned value, state change or side effect.

Distinctions & related ideas

Place the concept correctly

InputObjects/values supplied to the operation.
StateNames or mutable objects that may change during execution.
OutputReturned value, side effect, file, plot or exception to inspect.
Use deliberately

When it is appropriate

Use Install Python or Choose a Notebook Environment when it answers a defined question in Getting Started with Python and its inputs/assumptions match the current data or program state.

Boundary conditions

When to stop or reconsider

Reconsider Install Python or Choose a Notebook Environment when the required information is unavailable, the operation would violate a validation/data boundary, or a simpler operation answers the question more transparently.

Common mistakes

Failure modes to recognise

  • Running the operation on the wrong object/type or in the wrong environment.
  • Inferring correctness from “no exception” without checking the produced value/state.
  • Hiding a boundary case instead of making its behaviour explicit.
Verification

How to check the result

  • Trace a tiny input by hand and compare the runtime result.
  • Inspect type, value/shape and any mutation/side effect explicitly.
  • Run an edge or invalid case and confirm the exception/behaviour is deliberate.
Hands-on practice

Demonstrate understanding

Try this:

Construct a tiny example of Install Python or Choose a Notebook Environment. First identify the interpreter with its version and executable path. Then distinguish the operating-system terminal from the Python prompt. Predict the result before execution and explain one boundary or failure case.

Use the smallest values that expose the language rule. Write the expected value and type first, then compare the actual state/output with that prediction.
Knowledge check

Check reasoning, not memorisation

Which approach best demonstrates understanding of Install Python or Choose a Notebook Environment?

Quick reference

Remember the logic

Step 1Identify the interpreter with its version and executable path.
Step 2Distinguish the operating-system terminal from the Python prompt.
Step 3Create a virtual environment when a project needs isolated dependencies.
Step 4In a notebook, verify which kernel/interpreter the notebook is using.
Lesson summary

What to remember

  • A Python environment is the specific interpreter plus the packages available to it. Installing Python gives the operating system an interpreter executable; a notebook service adds a browser interface whose kernel points to a particular interpreter. The important question is therefore not only “is Python installed?” but “which Python is executing this code, and which packages belong to it?”
  • Identify the interpreter with its version and executable path.
  • Running the operation on the wrong object/type or in the wrong environment.
  • Trace a tiny input by hand and compare the runtime result.