What problem does Local Python Tools help us solve in a small Python program?
What should we predict before running the example?
What value, output, or error should we inspect after changing one line?
Objectives
Run a complete example for local Python, editors, terminals, and notebooks in Colab.
Explain the example line by line using plain language.
Change one part of the code and predict the result before running it.
Recognize one common mistake and use the error message as evidence.
Hands-on episode: Local Python Tools
The interpreter runs Python code, the editor helps you write files, the terminal runs commands, and notebooks mix code with explanation. A reliable setup means all four tools are pointing at the same Python environment.
We will learn this by running code, not by memorizing a definition first. Open the Colab notebook from the button above, find this section, and run each cell in order. Keep a small note beside the notebook with three columns: prediction, actual result, and what changed.
Example 1.1
The safest first local check is to ask Python which version is running and where it is installed.
Run the cell once without editing it. If the result is different from your prediction, leave the prediction visible and write one sentence about the difference. That sentence is more useful than a perfect first guess.
Explain Example 1.1
The first command asks the selected Python interpreter to report its version.
The second command runs a tiny Python program from the terminal.
sys.executable prints the path to the interpreter, which helps you notice when VS Code or Jupyter is using a different Python.
Now explain the example out loud or in a Markdown cell. Use short sentences: “this line creates…”, “this name stores…”, “this output appears because…”. If you cannot explain a line yet, run only the lines above it and inspect the values that exist at that moment.
Challenge 1.1
NoteChallenge
If your system uses python3 instead of python, run the same commands with python3. The important idea is not the exact command name; it is checking that the interpreter you are using is the one you intended.
Show a safe way to approach the challenge
Copy Example 1.1 into a new Colab cell.
Change exactly one value, name, condition, or line.
Write the expected output before running the cell.
Run the cell and compare the actual result with your prediction.
If the result surprises you, undo the change and try a smaller one.
Suggested first move: If your system uses python3 instead of python, run the same commands with python3.
Debugging checkpoint 1.1
WarningDebugging checkpoint
A very common mistake is installing a package with one Python and running code with another. Prefer python -m pip install package_name because it tells the same interpreter that will run your code to install the package.
Do not debug by rewriting the whole example. Read the error type or surprising output, inspect the closest value with print(...) or type(...), then change one thing. This is the same routine you will use in larger projects.
Apply it
Open VS Code, create hello.py, write one print statement, run it from the VS Code terminal, and compare the interpreter path with the one selected in the VS Code status bar.
Finish by adding a Markdown cell that answers: What did this example teach me that I can reuse in a project?
Key points
Learn the concept by running a complete, small example first.
Predict before execution so your thinking becomes visible.
Change one thing at a time so cause and effect stay clear.
Treat errors as clues about the exact line or value Python could not handle.
The problem this lesson solves
Colab is a great starting point, but eventually you will want Python on your own computer. Local tools let you save projects in folders, run scripts from files, use an editor, install packages, and work without depending on a browser session.
This lesson introduces four tools as one workflow:
Python interpreter: runs your code.
Terminal: lets you type commands.
VS Code: helps you edit and run project files.
Jupyter: gives notebook-style exploration on your computer.
How local Python tools work together
Local Python work connects files, commands, an interpreter, and output.
flowchart LR
editor["VS Code<br/>edit hello.py"] --> file["hello.py"]
terminal["Terminal<br/>python hello.py"] --> interpreter["Python interpreter"]
file --> interpreter
interpreter --> output["Output or traceback"]
interpreter --> packages["Packages via pip"]
notebook["Jupyter notebook"] --> interpreter
The same interpreter can run a .py script, support VS Code, and power a Jupyter notebook.
1. Install Python and verify it
Installing Python means adding the interpreter to your computer. The safest beginner habit is to verify installation before doing anything else.
A terminal is a place to type commands. You do not need to master every command. For this course, start with a small set.
Command
Meaning
pwd
show the current folder on macOS/Linux
cd folder_name
move into a folder
ls
list files on macOS/Linux
dir
list files on Windows
python file.py
run a Python script
Create a file named hello.py with this code:
print("Hello from a file")
Then run it from the folder that contains the file:
python hello.py
Common mistake: wrong folder
If you see a message like “file not found”, Python may be working in a different folder from the one containing your file. Check your current folder and list the files there.
VS Code is an editor for writing and organizing files. A good beginner setup is:
Open a project folder, not just a single file.
Install the Python extension if VS Code suggests it.
Select the interpreter that matches your terminal command.
Save files before running them.
Use the integrated terminal to run python file.py.
First VS Code script
Create a file named hello.py:
name ="Ada"print(f"Hello, {name}!")
Run it from VS Code’s terminal:
python hello.py
Why use files?
A .py file is good for code you want to keep, rerun, test, and share. A notebook is good for exploration and explanation. You will use both in this course.
WarningCommon mistake
If VS Code says a package is missing but the terminal can import it, VS Code may be using a different interpreter. Re-select the interpreter and run the check command again.
Jupyter lets you run notebooks on your own computer. A notebook is helpful when you want to mix code, notes, output, and plots.
A common beginner setup is:
python-m pip install notebookpython-m notebook
This installs and starts the classic notebook interface. Some learners prefer JupyterLab; the core idea is the same: code runs in cells, and output appears near the code.
Notebook vs script
Use a notebook when…
Use a .py file when…
you are exploring data
you want a reusable program
you want notes beside output
you want tests and command-line runs
you are learning a concept interactively
you are packaging or sharing code
Common mistake: hidden notebook state
Just like Colab, a local notebook remembers values from previously run cells. When confused, restart the kernel and run cells from top to bottom.