Site icon Ampersand Tutorials

How to Set Up Python and Run Your First Script (2026 Beginner Guide)

Quick answer: Install Python 3 from python.org, tick Add Python to PATH during setup, then run python --version in a terminal. Write print("Hello, World!") in a file called hello.py and execute it with python hello.py. That is the entire loop: write, run, repeat.

Part 1 of our Python series — the full 21-part path from zero to real software engineering.

Why environment setup matters

Most people who quit Python quit on day one — not because the language is hard, but because nothing runs. A misconfigured PATH, wrong Python version, or a text editor that saves .txt instead of .py blocks every script you ever try to run. Getting this right once means every tutorial in this series works on your machine without friction.

Python is an interpreted language: there is no compile step. You write a .py file, an interpreter reads it top to bottom and executes each line. Your job in this article is to install that interpreter and prove it runs.

Step-by-step: getting Python running

1. Install Python 3

2. Verify the install

Open a new terminal (old ones cache the PATH) and run:

python --version
# Python 3.12.x  (any 3.x is fine)

On Linux/macOS you may need python3 --version instead.

3. Write your first script

Create a folder python-playground, add a file hello.py:

# hello.py — my first Python script
print("Hello, World!")
print(2 + 2)

4. Run it

cd python-playground
python hello.py
# Hello, World!
# 4

What happened: the interpreter opened hello.py, ran each statement in order, and printed the results. # starts a comment — Python ignores everything after it on that line.

The two ways to run Python

ModeHow to startWhen to use
Interactive / REPLpython with no argumentTesting a line or two, quick math
Script modepython filename.pyEverything real

The REPL (>>> prompt) is a calculator with memory:

>>> 3 * 7
21
>>> exit()

Complete executable example

# first-day.py — combining everything from this article
print("=== My first Python run ===")
print("Python is executing me line by line.")
result = 10 * 3
print("10 * 3 =", result)
print("Done. Next up: data types.")

Common mistakes and edge cases

Key takeaways and challenge

Challenge: write predict.py that prints three lines — your name, today’s date, and the result of 2 10 (which is 1024 — exponentiation uses ). Then run it, edit a line, and run it again. Editing and re-running is the core loop of this entire series.

Want one-to-one help getting ramped in Python? Ampersand Academy offers hands-on training.

Do I need to install Python to start coding?

Yes. Python is interpreted, so the interpreter must run your files. Download Python 3 from python.org and tick Add Python to PATH on Windows during install.

What is the difference between Python 2 and Python 3?

Python 3 is the current standard; Python 2 reached end of life in 2020. Syntax differs (print is a function in 3), and nothing new is ever released for 2. Always install 3.x.

Do I need an IDE to write Python?

No. Any text editor plus a terminal is enough. Editors like VS Code or IDLE add convenience such as syntax highlighting, but the workflow is the same: write a .py file, run it with python.

Why is python not recognized in my terminal?

Python is not on your PATH, or the terminal was opened before installation. Re-run the installer and tick Add Python to PATH, then open a brand-new terminal and test python –version again.

What should my first Python script do?

The classic first script prints Hello, World! with print(). It proves the interpreter, PATH, and file extension handling all work before you move on to variables and logic.

Exit mobile version