Tutorials · Beginner
How to program in Python with AI
Learn how to program in Python with AI from scratch: install Python, pick your tool (free or paid), and write your first script with Claude or GitHub Copilot.
- Python
- Claude
- GitHub Copilot
- VS Code
In this guide you’ll learn how to program in Python with AI from scratch: you’ll install Python on your computer, pick an AI tool (free or paid), and write your first script with Claude or GitHub Copilot. No prior programming experience needed.
Pick your system (Windows or Mac) with the buttons above and tap each step to open it.
1 Install Python
Python is the programming language we’ll use. It’s free.
- Go to https://python.org/downloads
- The big yellow button downloads the latest version for your system.
- Open the downloaded
.exefile. - Before clicking “Install Now”, check the “Add Python to PATH” box (important: if you skip this, the next step will fail).
- Click “Install Now” and wait for it to finish.
- Open the downloaded
.pkgfile and follow the steps until “Close”.
To check it worked: open PowerShellthe Terminal and type:
python --version
python3 --version
If you see a number like Python 3.12.0, you’re set!
2 Pick your AI tool
You have several options, all work well for learning Python:
| Tool | Price | How it helps |
|---|---|---|
| GitHub Copilot Free | $0 | Suggests code as you type in VS Code (AI autocomplete) |
| Claude (claude.ai) | $0 (limited) | Chat: explains, writes full scripts, and fixes errors |
| ChatGPT (chat.openai.com) | $0 (limited) | Similar to Claude: explains and generates code by chat |
To start free today: open https://claude.ai in your browser and ask for Python code right in the chat, no extra setup needed.
For the full in-editor experience: install VS Code and add GitHub Copilot (Step 3). The free Copilot plan covers learning perfectly.
3 Install VS Code and GitHub Copilot
VS Code is the most popular code editor and GitHub Copilot integrates directly with it. The free Copilot plan includes 2,000 completions and 50 chats per month (confirm current limits at https://github.com/features/copilot/plans).
- Install VS Code from https://code.visualstudio.com (free).
- Open VS Code, go to the Extensions panel (
Ctrl + Shift + XCmd + Shift + X) and search for GitHub Copilot. Install the official GitHub extension. - A window will open to sign in with your GitHub account (create one free at https://github.com if you don’t have one).
- When you sign in, Copilot activates the free plan automatically.
Now, when you open a .py file and start typing, Copilot will show suggestions in gray. Press Tab to accept.
Want Claude integration instead of Copilot? See the tutorial How to connect Claude to Visual Studio Code.
4 Write your first script with AI
The basic flow for programming Python with AI is always the same: describe to the AI what you want, copy the code, and run it.
Option A: by chat (Claude.ai or ChatGPT)
- Open https://claude.ai in your browser.
- Type, for example: “Write a Python script that greets me by name and tells me what day it is.”
- Claude returns the code. Copy it.
- Open NotepadTextEdit, paste the code, and save it as
saludo.py(on your Desktop, for example).
Option B: in VS Code with Copilot
- Create a new file in VS Code and save it as
saludo.py. - Type a comment describing what you want:
# Script that greets by name and shows today's date - Copilot suggests the code below. Press
Tabto accept it.
Whether by chat or autocomplete, the AI generates the code for you: your job is to describe clearly what you want and run it.
5 Run your script
- Open PowerShellthe Terminal.
- Navigate to where you saved the file. If you saved it on the Desktop:
cd $HOME\Desktop
cd ~/Desktop
- Run the script:
python saludo.py
python3 saludo.py
You should see the greeting message on screen. You just ran your first Python program with AI!
If you see an error, don’t close it: copy the full message and paste it into Claude or ChatGPT. Ask: “I get this error running my Python script, what’s wrong?”. You’ll learn more from the error than from perfect code.
Debug errors with AI
Finding errors is normal, even for programmers with years of experience. With AI, debugging is much faster:
- When a script fails, the terminal shows an error message (starts with
TracebackorError:). - Copy the entire message.
- Open Claude or ChatGPT and write: “I get this error running my Python script: [paste error here]. What’s wrong and how do I fix it?”
- The AI explains the cause and gives you the corrected code.
You can also share the full script with the error so the AI has more context: “Here’s my code: [code]. I get this error: [error]. Help me fix it.”
For more AI debugging techniques, see the tutorial How to debug code errors with AI.
Projects you can build with Python and AI
Once you have Python and an AI tool, the possibilities are enormous. Start small and grow:
- Custom calculator: a script that adds, subtracts, and multiplies with terminal menus.
- File organizer: moves files from one folder to others based on type (photos, documents, videos).
- CSV reader: reads a spreadsheet and shows sorted data.
- Word counter: analyzes a text and shows how often each word appears.
- Reminder bot: shows a message on screen when run, ideal to automate with the task scheduler.
For larger projects, like apps with a graphical interface or a database, see the tutorial How to create an app with artificial intelligence (no coding).
If something goes wrong
| Problem | Fix |
|---|---|
python is not recognized as a command | On Windows, reinstall Python and check “Add Python to PATH”; on Mac use python3 instead of python |
| The script does nothing when run | Check that the filename ends in .py and that you’re in the right folder |
| The AI gives me code that doesn’t work | Copy the error and send it back: “This didn’t work, here’s the error: [error]“ |
| Copilot won’t suggest code | Check that the extension is active and you’re signed in with your GitHub account |
| I don’t know how to navigate to the right folder in the terminal | Ask the AI: “How do I navigate with the terminal to my Desktop on Windows/Mac?” |
Frequently asked questions
Can you program in Python with AI for free?
Yes. GitHub Copilot has a free plan with 2,000 completions and 50 chats per month, and claude.ai offers limited free access. Both are enough to learn Python from scratch.
Do I need to know how to code to get started?
No. AI writes the code for you, explains it line by line, and fixes errors. You can start with zero prior experience.
Which tool is better for programming Python with AI: Claude or GitHub Copilot?
It depends on the use. Copilot is ideal for in-editor autocomplete as you type. Claude is better for complete projects, detailed explanations, and learning from scratch. Many people use both.
How long does it take to learn Python programming with AI?
With AI you can write useful scripts from day one. For solid foundations, 4 to 8 weeks with 30 minutes of daily practice.
Does Python need to be installed?
Yes, Python must be installed on your computer to run code locally. Installation is free and takes under 5 minutes.