Getting Started
Install Python, run your first line of code, and meet the two main ways you'll interact with it.
1. Install Python
Head to python.org/downloads and grab the latest version (Python 3.x). On Windows, tick the box that says "Add Python to PATH" during install — it makes your life much easier later.
To check it worked, open a terminal (Command Prompt on Windows, Terminal on macOS/Linux) and type:
python --version
You should see something like Python 3.12.1. If you do — congratulations, you have Python.
python3 instead of python.
If python --version doesn't work, try python3 --version.
2. The two ways to run Python
You'll mostly use Python in one of two ways:
- The REPL — an interactive prompt for trying things out.
- A script file (
.py) — code you save and run.
The REPL
In your terminal, type python (or python3) and press Enter. You'll see a
prompt that looks like >>>. Type a line of code and Python answers immediately:
print("Hello, world!")
To leave the REPL, type exit() and press Enter.
A script file
Open any text editor (VS Code is a great free choice). Create a new file called
hello.py and put this in it:
# My very first Python program
print("Hello, world!")
print("Welcome to Python.")
Save it, then in your terminal, navigate to that folder and run:
python hello.py
3. Comments
Anything after a # on a line is a comment — Python ignores it. Comments
are notes for humans:
# This whole line is a comment
print("Hi") # this part is too