Lesson 2 of 405%
(Progress persistence is disabled until Phase 9)
Python
Beginner
Installing and Running Python
Learn how to get Python set up on your machine and run your first script.
Installing and Running Python
What You’ll Learn
You’ll learn how to download Python, verify the installation, and run basic Python code from the terminal.
Installation
To use Python on your computer, you need to download and install it from the official website.
- Go to python.org/downloads.
- Download the latest version for your operating system.
- IMPORTANT (Windows): During installation, make sure to check the box that says “Add Python to PATH”.
Verifying Installation
Once installed, open your terminal or command prompt and type:
python --version
# or
python3 --version
Expected Output:
Python 3.12.0
Running Python Code
You can run Python code in two ways:
1. Interactive Mode (REPL)
Type python in your terminal to open the interactive shell. You can type Python commands directly and see immediate results.
>>> 5 + 5
10
>>> print("Hello")
Hello
2. Running a Script File
Create a file named script.py and add your code. Then, run it from the terminal:
python script.py
Common Mistakes
- Forgetting to check “Add to PATH”: If you get a “command not found” error when typing
python, this is the most likely cause. You’ll need to reinstall and check the box, or add it to PATH manually.