← All articles· Vibe Coding

How to Automate Tasks with Python and AI (Beginner Guide)

Written by Saad AAI Expert Instructor with experience at Deloitte, PwC, BMO, and Microsoft. Teaching 24,318+ students worldwide.View the Complete AI Bootcamp →July 5, 202516 min read

Learn to automate boring tasks using Python and AI — even if you have never coded before. AI writes the code for you, you just describe what you need.

Why Python and AI Are the Ultimate Automation Combo

Let me paint a picture for you. It is Monday morning. You sit down at your desk and realize you need to rename 200 files, send follow-up emails to 30 clients, pull data from a website, generate a weekly report, and schedule social media posts for the week. That is easily four to five hours of mind-numbing, repetitive work.

Now imagine all of that happening automatically while you sip your coffee. Not in some futuristic fantasy. Right now. Today. With a few lines of Python code that you did not even have to write yourself because an AI wrote it for you.

That is the power of combining Python with AI tools like ChatGPT and Claude. You describe the task in plain English, the AI generates the Python script, you run it, and the work gets done. No computer science degree required. No years of study. Just a clear description of what you want to happen.

This is not hype. This is the most practical skill you can learn in 2025, and this guide will walk you through everything step by step.

Person working on laptop with code on screen in modern workspace
Person working on laptop with code on screen in modern workspace

---

Why Python Is the Go-To Language for Automation

You might be wondering: why Python specifically? There are hundreds of programming languages out there. What makes Python the obvious choice for automation?

It Reads Like English

Python was designed to be readable. Look at this line of code:

```python

for file in folder:

rename(file)

```

Even if you have never written a single line of code, you can probably guess what that does. It goes through every file in a folder and renames it. That is Python. It is not cryptic. It is not intimidating. It is almost like writing pseudocode in plain language.

It Has a Library for Everything

Python has an enormous ecosystem of pre-built tools called libraries. Want to send emails? There is a library for that. Want to scrape websites? Library. Automate spreadsheets? Library. Work with PDFs? Library. You are almost never building from scratch. You are assembling building blocks.

AI Tools Are Incredible at Writing Python

Here is the real secret weapon. AI models like ChatGPT and Claude are exceptionally good at writing Python. Because Python is the most popular programming language in the world, these models have been trained on millions of Python examples. When you ask an AI to write a Python script, the output is usually clean, functional, and ready to run.

The Community Is Massive

If you ever get stuck, Python has one of the largest developer communities on the planet. Stack Overflow, Reddit, YouTube, GitHub — there are answers everywhere. And now with AI assistants, you do not even need to search. You just ask.

---

Setting Up Python (With AI Holding Your Hand)

Let us get practical. Before you can run any automation scripts, you need Python installed on your computer. Do not worry, this is easier than you think, and you can literally ask AI to guide you through every step.

Step 1: Download Python

Go to [python.org](https://python.org) and download the latest version (Python 3.12 or newer). Click the big download button for your operating system. On Windows, make sure to check the box that says "Add Python to PATH" during installation. This is the one step people forget, and it causes headaches later.

On Mac, Python comes pre-installed, but it is usually an older version. Download the latest from the website anyway.

Step 2: Verify the Installation

Open your terminal (Command Prompt on Windows, Terminal on Mac) and type:

```

python --version

```

You should see something like `Python 3.12.x`. If you do, you are ready to go.

Step 3: Install a Code Editor

You need a place to write and run your scripts. Visual Studio Code (VS Code) is free, lightweight, and perfect for beginners. Download it from [code.visualstudio.com](https://code.visualstudio.com). Install the Python extension from the extensions marketplace once you have it running.

Step 4: Let AI Be Your Setup Assistant

If anything goes wrong during setup, do not panic. Copy the error message and paste it into ChatGPT or Claude. Say something like: "I am trying to install Python on Windows 11 and I got this error. How do I fix it?" The AI will walk you through the solution step by step. This is genuinely how professionals troubleshoot too.

---

The Magic Workflow: Describe, Generate, Run

Before we dive into the projects, let me explain the workflow you will use for every single automation task. It is beautifully simple:

1. Describe what you want to automate in plain English

2. Generate the Python script using ChatGPT or Claude

3. Run the script on your computer

4. Refine by telling the AI what to adjust

That is it. You are not memorizing syntax. You are not studying documentation. You are having a conversation with an AI and letting it do the heavy lifting.

Here is an example prompt you might send to Claude:

"Write a Python script that goes through all the files in my Downloads folder, checks the file extension, and moves each file into a subfolder based on its type — images into an Images folder, documents into Documents, videos into Videos, and everything else into Other."

Within seconds, you get a complete, working script. You save it as a `.py` file, run it, and your Downloads folder is instantly organized. That task would have taken you 20 minutes by hand. The script does it in 2 seconds.

Organized desk with laptop showing clean file management
Organized desk with laptop showing clean file management

---

Project 1: The Automatic File Organizer

Let us start with the most satisfying automation you will ever build. If your Downloads folder looks like a digital junk drawer, this is your rescue mission.

What It Does

This script scans a folder, identifies every file by its extension, and automatically sorts them into categorized subfolders. Images go to Images. PDFs go to Documents. Videos go to Videos. No more scrolling through hundreds of random files.

How to Build It With AI

Open ChatGPT or Claude and type this prompt:

"Write a Python script that organizes files in a specified folder. It should create subfolders for different file types (Images for .jpg .png .gif .webp, Documents for .pdf .docx .xlsx .txt, Videos for .mp4 .mov .avi, Audio for .mp3 .wav, Code for .py .js .html .css, and Other for everything else). The script should move each file into the correct subfolder. Add error handling and print a summary of how many files were moved to each category."

What You Will Learn

Even though the AI writes the code, you will start noticing patterns. You will see how Python uses `os` and `shutil` libraries to work with files. You will see how `for` loops iterate through items. You will see how `if-elif-else` statements make decisions. Without even trying, you are absorbing programming concepts.

Making It Better

Once the basic version works, ask the AI to enhance it:

  • "Add a feature that checks for duplicate file names before moving"
  • "Make it log every action to a text file"
  • "Add a dry-run mode that shows what would happen without actually moving files"

Each refinement teaches you something new while solving a real problem.

---

Project 2: The Automated Email Sender

Sending personalized emails to multiple people is one of those tasks that feels simple but eats up enormous amounts of time. Let Python handle it.

What It Does

This script reads a list of names and email addresses from a spreadsheet or CSV file, personalizes an email template for each person, and sends them all automatically. Perfect for follow-ups, newsletters, event invitations, or client outreach.

How to Build It With AI

Use this prompt:

"Write a Python script that reads a CSV file with columns 'name' and 'email', personalizes an email template by inserting the recipient's name, and sends the email using Gmail's SMTP server. Include error handling, a delay between emails to avoid spam filters, and a log of successfully sent emails. Use environment variables for the email password so it is not hardcoded."

Important Notes

  • You will need to set up an App Password in your Gmail account (regular passwords will not work due to security settings). Ask the AI how to do this.

Ready to master AI?

Our Complete AI Bootcamp covers prompt engineering, ChatGPT, MidJourney, vibe coding, AI agents and more — with 110+ video lessons and 2,000+ prompts.

  • Always test with your own email address first before sending to real recipients.
  • Add a 2 to 5 second delay between emails to avoid being flagged as spam.
  • Never use this for unsolicited bulk email. That is spamming. Use it for legitimate business communication with people who expect to hear from you.

Real World Use Case

Imagine you run a small freelance business. Every Friday, you need to send project updates to 15 different clients. Each email needs their name, their specific project name, and a status update. Without automation, that is 45 minutes of copying, pasting, and personalizing. With this script, it is done in 30 seconds.

---

Project 3: The Web Scraper

The internet is the largest database in the world, but getting data out of websites manually is painfully slow. Web scraping automates that extraction.

What It Does

A web scraper visits a website, reads the content, and extracts specific information you care about — product prices, article headlines, job listings, real estate data, weather information, or anything else displayed on a webpage.

How to Build It With AI

Try this prompt:

"Write a Python script using the requests and BeautifulSoup libraries that scrapes [specific website or type of website]. It should extract [specific data points] and save the results to a CSV file. Include error handling for network issues, add headers to mimic a real browser, and add a polite delay between requests."

A Practical Example

Say you are researching laptop prices across different retailers. You could manually visit ten websites, find the laptop you want, write down the price, and repeat. Or you could ask AI to write a scraper that visits all ten sites, extracts the prices, and creates a neat spreadsheet comparing them. The script runs in under a minute.

Ethics and Best Practices

Web scraping is powerful, but you need to be responsible:

  • Check the website's robots.txt file to see if scraping is allowed
  • Do not hammer servers with hundreds of requests per second. Add delays between requests
  • Respect rate limits and terms of service
  • Do not scrape personal data without consent
  • Use scraped data for personal research, not redistribution without permission

Ask the AI about these considerations. It will help you write respectful, ethical scrapers.

---

Project 4: The Automatic Report Generator

Every business, team, and freelancer needs reports. Weekly summaries, monthly analytics, project status updates. They are necessary but tedious to create manually. Let us automate them.

What It Does

This script takes raw data from a spreadsheet, database, or API, processes it, generates charts and summaries, and produces a beautiful PDF or HTML report. Automatically. On a schedule if you want.

How to Build It With AI

Use this prompt:

"Write a Python script that reads sales data from a CSV file, calculates key metrics (total revenue, average order value, top-selling products, month-over-month growth), generates bar charts and line graphs using matplotlib, and compiles everything into a professional-looking PDF report with headers, summaries, and the charts embedded. The report should include today's date in the filename."

Why This One Is a Game Changer

Reports are the perfect automation candidate because they follow the same structure every time, but with different data. Once you have the script, generating the report takes seconds instead of hours. Your boss thinks you are a wizard. Your clients are impressed by the consistency. And you did not spend your afternoon copying numbers into slides.

Leveling Up

Once the basic report works, ask the AI to add:

  • "Send the report as an email attachment automatically"
  • "Pull data from a Google Sheet instead of a local CSV"
  • "Add a comparison to the previous period's data"
  • "Generate an executive summary paragraph using AI"

That last one is particularly powerful. You can use Python to call the OpenAI or Anthropic API, feed it your data, and have it write a human-readable summary paragraph for the top of your report. Automation all the way down.

---

Project 5: The Social Media Scheduler

Consistent social media posting is crucial for building an audience, but manually posting every day is a time sink. This automation takes care of it.

What It Does

This script reads a content calendar (a simple spreadsheet with dates, captions, and image paths), and posts to your social media accounts at the scheduled times. It can handle Twitter/X, LinkedIn, and other platforms that offer API access.

How to Build It With AI

Use this prompt:

"Write a Python script that reads a social media content calendar from a CSV file (with columns: date, time, platform, caption, image_path), connects to the Twitter API using tweepy, and posts the content at the scheduled time. Include error handling, logging, and a check to prevent duplicate posts."

Getting API Access

Most social media platforms require you to create a developer account and get API keys before you can post programmatically. This is free for basic use. Ask the AI:

"How do I set up a Twitter developer account and get API keys for automated posting?"

It will walk you through the entire process.

The Bigger Picture

This project teaches you something important about automation: the real power is in combining multiple automations. Imagine this pipeline:

1. An AI generates social media captions based on your blog posts

2. A script formats them and adds them to your content calendar

3. Another script posts them at optimal times

4. A final script scrapes the analytics and generates a weekly performance report

That entire workflow can run without you touching it. That is not just automation. That is building a system.

Smartphone showing social media apps on a desk with laptop
Smartphone showing social media apps on a desk with laptop

---

Using AI to Write Your Code: Tips That Actually Matter

You now have five concrete projects. But let me share some tips for getting the best results when you ask AI to write your automation scripts.

Be Specific About Your Environment

Always tell the AI what operating system you are using, what version of Python you have, and any constraints you are working with. "I am on Windows 11 with Python 3.12" gives much better results than just "write a Python script."

Ask for Error Handling

Always include "add error handling" in your prompt. Without it, your script will crash the moment something unexpected happens. With it, the script will gracefully handle problems and tell you what went wrong.

Request Comments in the Code

Add "include detailed comments explaining what each section does" to your prompt. This turns the generated code into a learning tool. You will understand what every part does, which makes it easier to modify later.

Iterate, Do Not Start Over

If the script is 80% right but needs changes, do not write a new prompt from scratch. Copy the code back to the AI and say "this script works but I need it to also do X" or "change the part that does Y to instead do Z." Building on existing code is faster and produces better results.

Test With Small Data First

Before running your email sender on 500 contacts or your scraper on 1000 pages, test with 2 or 3 items first. Make sure everything works correctly on a small scale before scaling up. This saves you from embarrassing mistakes.

---

How to Run Your Python Scripts

Once the AI generates your script, you need to actually run it. Here is how.

Step 1: Save the Script

Copy the code from ChatGPT or Claude. Open VS Code, create a new file, paste the code, and save it with a `.py` extension. For example, `file_organizer.py`.

Step 2: Install Required Libraries

Most scripts use external libraries. The AI will tell you which ones are needed. Install them by opening your terminal and running:

```

pip install library_name

```

For example, if the script uses BeautifulSoup for web scraping:

```

pip install beautifulsoup4 requests

```

Step 3: Run the Script

In your terminal, navigate to the folder where you saved the script and run:

```

python file_organizer.py

```

That is it. The script executes, does its job, and prints any output to the terminal.

Step 4: Troubleshoot With AI

If you get an error, copy the entire error message and paste it to the AI. Say "I ran this script and got this error. How do I fix it?" Nine times out of ten, the fix is simple and the AI will explain it clearly.

---

Scheduling Your Automations to Run Automatically

Running scripts manually is fine, but the real magic happens when they run on a schedule without you doing anything.

On Windows: Task Scheduler

Windows has a built-in tool called Task Scheduler. You can set it to run your Python script at any time — every morning at 8 AM, every Friday at 5 PM, every hour, whatever you need. Ask the AI: "How do I set up Windows Task Scheduler to run a Python script every day at 9 AM?"

On Mac: Cron Jobs

Mac and Linux use cron jobs for scheduling. You edit a simple text file to define when your script should run. Ask the AI: "How do I set up a cron job on Mac to run a Python script every weekday at 8 AM?"

Cloud Scheduling

If you want your scripts to run even when your computer is off, you can deploy them to the cloud. Platforms like PythonAnywhere, AWS Lambda, or Google Cloud Functions let you run Python scripts on a schedule for free or very cheaply. The AI can guide you through setting these up.

---

You Do Not Need to Become a Programmer

Here is what I want you to take away from this guide. You do not need to become a software engineer. You do not need to memorize Python syntax. You do not need to understand every line of code the AI generates.

What you need is:

  • The ability to clearly describe what you want automated. The better you describe the task, the better the AI's output.
  • Basic comfort with running scripts. Just enough to save a file and type a command in the terminal.
  • The willingness to iterate. The first version might not be perfect. That is fine. Tell the AI what to fix and try again.

That is the entire skill set. And with it, you can automate hours of repetitive work every single week. You can build systems that run while you sleep. You can solve problems that used to require hiring a developer.

Python plus AI is not just a tool. It is a superpower. And now you know exactly how to start using it.

---

Your Next Step

Pick one of the five projects above. The file organizer is the easiest starting point. Open ChatGPT or Claude, type the prompt, get the script, and run it. You will go from zero to your first working automation in under 30 minutes.

Once that first script works and you feel the rush of watching your computer do tedious work for you automatically, you will never want to go back to doing things manually. That is the moment everything changes.

Welcome to the age of personal automation. Let us build something.

Written by Saad A

AI Expert Instructor with experience at Deloitte, PwC, BMO, and Microsoft. Teaching 24,318+ students worldwide.

Ready to master AI?

Our Complete AI Bootcamp covers prompt engineering, ChatGPT, MidJourney, vibe coding, AI agents and more — with 110+ video lessons and 2,000+ prompts.

Related Articles