Python Basics
Python Installation and Setup
Before you can write Python programs on your own computer, you need to install Python and pick a place to write code. This guide covers Windows, Mac and Linux.
Installing Python on Windows
- Go to python.org/downloads and download the latest Python 3 installer
- Run the installer and tick the box "Add Python to PATH" — this step is important
- Click "Install Now" and wait for setup to finish
- Open Command Prompt and confirm the install
Installing Python on Mac
macOS often ships with an old Python version, so install the latest one separately. Download the macOS installer from python.org, or if you use Homebrew, run brew install python3 in the terminal.
Installing Python on Linux
Most Linux distributions include Python already. To install or upgrade it on Debian/Ubuntu-based systems, use your package manager.
sudo apt update
sudo apt install python3 python3-pipChecking Your Python Version
Once installed, always confirm the installation by checking the version number from your terminal or command prompt.
python --version
# or on Mac/Linux
python3 --versionChoosing an Editor: IDLE vs VS Code
Python comes bundled with a simple built-in editor called IDLE, which is fine for quick tests. For serious practice, most developers use Visual Studio Code (VS Code) with the free Python extension, which adds auto-complete, error highlighting and an integrated terminal.
If installation feels tricky, you can still practice everything in this tutorial using a free online Python compiler in your browser — no setup required.
Writing and Running Your First Script
Create a new file named hello.py, add one line of code, save it, then run it from your terminal.
print("Python is set up correctly!")python hello.py