Python Lesson 1: Install Python and Run Your First Program

📎 This article includes 2 downloadable practice files ↓

⏱ 2 min read

📘 Python Beginner Course · Lesson 1 of 12

In this article
  1. Install on Windows
  2. An editor: VS Code
  3. Your first program
  4. The interactive prompt
  5. Installing packages
  6. Where beginners go wrong
  7. Practice

Python is free, runs on any computer, and you can write something useful in your first hour. This lesson gets it installed and running, which is honestly the hardest step for most beginners.

Install on Windows

  1. Go to python.org › Downloads and get the latest Python 3 (3.12 or newer). The Microsoft Store version also works.
  2. Run the installer and tick “Add python.exe to PATH” on the first screen. This is the step everyone misses.
  3. Click Install Now.
  4. Open Command Prompt or PowerShell and type python --version. You should see “Python 3.12.x”.

On Mac, install from python.org and use python3 instead of python.

An editor: VS Code

Install Visual Studio Code (free), then the Python extension from Microsoft. Open a folder (File › Open Folder), create lesson-01.py, and click the ▶ button to run. IDLE, which comes with Python, is fine for first steps too.

Your first program

print("Hello from Python!")
print("2 + 3 =", 2 + 3)
print("GST on 1000 at 18% is", 1000 * 18 / 100)

Save it and run from the terminal in that folder:

python lesson-01.py
💡 In VS Code, Ctrl+` opens a terminal already in your project folder. Most ‘file not found’ errors come from running a script from the wrong folder.

The interactive prompt

Type python with no file name and you get >>>. Type 12 * 60 and press Enter: 720. It’s a calculator and a place to test ideas. Type exit() to leave.

Installing packages

Python’s power is in packages. Lessons 8-12 need two:

pip install pandas openpyxl

If pip isn’t found, use python -m pip install pandas openpyxl.

Where beginners go wrong

Problem Fix
‘python’ is not recognized Reinstall with “Add to PATH” ticked, or use py on Windows
Typing print(…) into the terminal, not the prompt Run python first, or put code in a .py file
Saving as lesson.py.txt Turn on file extensions in Explorer
Spaces in folder names causing trouble Use a simple folder like C:\python-course

Practice

Download the script (and data file, if listed) below into one folder. Open a terminal in that folder and run python lesson-NN.py. Compare with the expected output, then change something and run it again: that’s how Python is learned.

📎 Practice files for this article

  • 🐍
    Lesson 1 scriptThe complete script from this lesson, tested.
    ⬇ PY · 211 B
  • 📄
    Expected outputWhat the script prints when you run it.
    ⬇ TXT · 92 B

Free to use for learning. Files with macros (.bas) are plain text — import them with Alt+F11 → File → Import File, and always test on a copy.

✨ Ask AI about this article

Stuck on a step? Ask a question and the AI answers using this article.

Free · AI can be wrong