Definition
Where do you actually write and run Python?
A Python environment is the set of tools used to write and run Python: the interpreter that runs the code, an editor or notebook to write it in, and the libraries the code uses. Common choices are a browser playground, Jupyter notebooks, VS Code and Google Colab.
In simple words
For learning, the playground on this site is enough: it runs Python in your browser with nothing to install. Data scientists like notebooks, where code and results sit together in cells. Developers building full applications use an editor such as VS Code. Colab is a free online notebook with a GPU for heavier AI work.
Overview
- A Python environment is the interpreter plus the libraries and tools you use to write and run code.
- You can install Python from python.org, use a distribution such as Anaconda, or work online without installing anything.
- pip installs extra libraries from the Python Package Index (PyPI), which hosts hundreds of thousands of packages.
- Virtual environments keep each project's libraries separate so that versions do not clash.
- Check your setup with python --version and by running a one-line program.
- This site's code boxes run Python in your browser through Pyodide, so you can start before installing anything.
Why it matters
Choosing the right tool saves time. Every later module uses notebooks for data work and an editor for building applications, so knowing both from the start makes the rest smoother.
Key terms
- Environment
- The interpreter, editor and installed libraries used to run your code.
- Notebook
- A document of cells mixing code, output and text, such as Jupyter or Google Colab.
- IDE
- An integrated development environment: an editor with tools such as running, debugging and suggestions.
- pip
- Python's package installer, used to add libraries.
- Virtual environment
- An isolated folder with its own Python and libraries for one project.
- Terminal
- A text window where you type commands to the computer.
Types
There are several kinds of place to write and run Python. Most programmers use more than one, depending on the task.
1. Interactive shell (REPL)
A prompt (>>>) where each line you type is run immediately and its result shown.
- How it works: Type python in a terminal; the Read-Eval-Print Loop reads a line, evaluates it, prints the result and waits for the next.
- Example: >>> 7 * 6 prints 42 straight away.
- When to use it: Use it to test a small idea, check how a function behaves or do quick calculations.
2. Code editor or IDE
A program for writing, running and debugging .py files, such as VS Code, PyCharm, Thonny or IDLE.
- How it works: You save code in files, and the editor adds colour highlighting, error hints, auto-completion and a debugger.
- Example: Writing marks_analyser.py in VS Code and running it with one click.
- When to use it: Use it for real projects with many lines or files, which you will save, share and maintain.
3. Notebooks (Jupyter)
A document of cells where code, its output, charts and explanations sit together.
- How it works: Each cell runs on its own and remembers earlier results, so you can explore data step by step and see charts inline.
- Example: Loading a CSV in one cell, plotting it in the next and writing notes in between.
- When to use it: Use it for data analysis, machine-learning experiments and teaching; move finished code into .py files.
4. Online and cloud environments
Websites that run Python for you, such as Google Colab, Replit or a browser runtime like Pyodide.
- How it works: Code runs on a remote server or inside the browser, with common libraries already installed; Colab also offers free GPU time for limited use.
- Example: Training a small neural network in Colab from a school computer without installing Python.
- When to use it: Use it when you cannot install software, need a GPU, or want to share runnable work with a link.
5. Virtual environments (venv, conda)
An isolated folder with its own Python and libraries for one project.
- How it works: python -m venv .venv creates it; after activating it, pip install puts libraries only there, and requirements.txt records the versions.
- Example: One project uses pandas 1.5 while another needs pandas 2.2, without clashing.
- When to use it: Use it for every project that installs libraries, so it can be rebuilt on another computer.
Explained in detail
Four ways to start
You do not need to install anything to begin. The examples on this site run in your browser. When you are ready for more, there are three common next steps. Google Colab runs Jupyter notebooks in the cloud for free with a Google account, and already has most AI libraries installed, which makes it popular for machine learning lessons. Installing Python from python.org plus an editor such as VS Code gives you a full setup on your own computer that works offline. Anaconda is a larger installation that bundles Python, Jupyter and hundreds of data-science libraries together.
Scripts and notebooks
| Script (.py file) | Notebook (.ipynb) | |
|---|---|---|
| How it runs | The whole file, top to bottom | One cell at a time, in any order you choose |
| Best for | Programs, tools and anything reused | Exploring data, experiments and teaching |
| Output | In the terminal | Right below each cell, including charts |
| Common trap | Forgetting to save before running | Running cells out of order and getting confusing results |
Installing libraries with pip
Python comes with a standard library, but most AI work needs extra packages. You install them from the Python Package Index, PyPI, with pip, for example by typing pip install numpy in a terminal, or !pip install numpy in a Colab cell. Once installed, you bring a library into a program with import numpy. A common beginner surprise is installing a package for one Python on the computer and running another; using python -m pip install numpy ties the install to the Python you actually run.
Virtual environments
Different projects often need different versions of the same library. A virtual environment is a separate folder with its own copy of Python's package list, so installing something for one project cannot break another. You create one with python -m venv .venv and activate it before installing. You will not need this for the early lessons, but it becomes important once you build real projects.
Whatever you choose, check your version with python --version; this course assumes Python 3.10 or newer.
How it works
| Tool | Best for | Install needed? |
|---|---|---|
| Browser playground (this site) | Learning and quick experiments | No |
| Jupyter notebook | Data analysis with code and charts together | Yes, or use Colab |
| Google Colab | Notebooks with free GPUs, in the cloud | No, needs a Google account |
| VS Code | Full projects with many files | Yes |
In a notebook, code lives in cells. You run one cell at a time, and the output appears right below it. Variables stay in memory between cells.
In code
A quick check that Python works, wherever you run it.
import sys
print("Python is working!")
print("Major version:", sys.version_info.major)
print("2 to the power 10 is", 2 ** 10)Output
Python is working! Major version: 3 2 to the power 10 is 1024
Try it yourself
Match the tool to its use
Which tool fits each situation best?
- Trying a line of Python on a school computer with nothing installed
- Exploring a dataset with charts next to the code
- Training a model that needs a GPU, for free
- Building an app with many files
Open and run a notebook
Optional, if you have a Google account.
- Open colab.research.google.com and create a new notebook.
- Type print("Hello from a notebook") in the first cell and press Shift + Enter.
- In a new cell, set x = 5. In the next cell, print x * 2. Notice that x is remembered.
Common mistakes
- Spending hours installing tools before writing any code. Start in the browser.
- Running notebook cells out of order and getting confusing results.
- Mixing up Python 2 and Python 3 tutorials. Always use Python 3.
Check yourself
Summary
- An environment is the interpreter, an editor or notebook, and libraries.
- Start in the browser; use notebooks for data and editors for apps.
- Colab gives free cloud notebooks with GPUs.
Finished reading?
Sources: Project Jupyter