Python ยท Chapter 2 of 45

Python Install & Setup

To run Python locally, download the installer from python.org. On Windows tick 'Add Python to PATH' during install so you can run `python` from any terminal.

Once installed, you can run Python interactively by typing `python` in a terminal, or run a script file with `python file.py`.

Syntax
python file.py

Verify the install

Open a terminal (or Command Prompt) and run `python --version`. You should see a version like 'Python 3.12.0'. If not, re-install and enable PATH.

Editors and IDEs

Popular choices are VS Code (free), PyCharm Community (free) and Thonny (great for beginners). Online options include Replit and Google Colab.

Example 1 (bash)
python --version
Output
Python 3.12.0

Prints the installed Python version.

Example 2 (bash)
python hello.py
Output
Hello, World!

Runs a script named hello.py.

Key points

  • Download Python from python.org.
  • Enable 'Add Python to PATH' on Windows.
  • Test with `python --version`.
  • Use VS Code or PyCharm as your editor.
๐Ÿ’ก Note: Prefer python.org's installer over the Microsoft Store version โ€” it works better with PATH and virtual environments.

๐Ÿ“ Quick Quiz

1. Which command shows the installed Python version?

2. The official website to download Python is:

3. How do you run a script named app.py?