Writing code has always felt like something "you need a computer science degree for" — but with today's AI assistants, that's no longer true. You don't need to know how to code; you need to know how to ask. This tutorial shows you how to use ChatGPT (or Claude, Gemini and similar AI chat tools) to write a genuinely useful Python script from scratch — your first script in about 10 minutes.
Step 1: Don't just say "write me a program" — be specific about three things
AI can't read your mind. A vague question gets a vague answer. A good prompt covers three things:
- What you want to do — the goal
- What the input is — which file, what format
- What the output should be — the result
Bad example: "Write me a program" — the AI has no idea what you want. Good example: "I have a CSV file with four columns — date, product, quantity, unit price. Write a Python program that calculates total sales for each product and outputs a new CSV." The more precise your question, the more useful the answer.
Step 2: A real example — a script that organises your photos
Say your phone is full of photos with messy filenames. Let's ask AI to write a script that sorts them into folders by capture date.
Here's a prompt you can paste straight into ChatGPT:
ChatGPT will generate code similar to this:
Step 3: Install the packages you need
The code above uses the Pillow (PIL) library to read photo metadata. Before running it the first time, install it:
Step 4: Run it — and let AI help you debug
If it errors out, don't panic. Paste the whole error message back to the AI and it will explain what's wrong and how to fix it. For example, ModuleNotFoundError: No module named 'PIL' simply means Pillow isn't installed yet.
Step 5: Reading it yourself is how you actually learn
AI wrote the code, but don't just copy-paste. Ask it follow-up questions: "What does os.listdir do here?" "Why do I need try/except?" That's how you move from "relying on AI" to "using AI" — and gradually learn to make changes yourself.
Things to watch: AI isn't always right
AI sometimes produces buggy or unsafe code. Keep a few things in mind:
- For code that deletes or moves files, test it in a throwaway folder first
- Always review AI-generated code before running it on company data
- Don't paste sensitive company data into public AI tools
Summary
This Python tutorial summary: AI won't replace you — but someone who knows how to use AI will replace someone who doesn't. Writing code has gone from "needs a four-year degree" to "know how to ask". Starting today, pick one repetitive task and ask AI to help you automate it.