Skip to main content

Command Palette

Search for a command to run...

How to Use Python to Automate Daily Tasks: A Step-by-Step Tutorial for Beginners

Save Time and Boost Productivity with Python Automation

Updated
5 min read
How to Use Python to Automate Daily Tasks: A Step-by-Step Tutorial for Beginners
A

Hey! I'm a passionate Full-Stack Developer who loves turning ideas into scalable web apps. I specialize in NestJS, React, and MongoDB, and enjoy working on modern product experiences with clean UI and solid backend architecture. Currently exploring fintech integrations like Razorpay and PayPal.

Follow me for practical coding tips, tutorials, and insights from real-world projects. Let’s build something awesome together! 🔥

Do you spend hours on repetitive tasks like renaming files, sending emails, or managing spreadsheets? With Python automation, you can save time and eliminate manual work by writing simple scripts.

In this guide, you’ll learn how to automate daily tasks using Python, even if you're a beginner. We'll cover real-world examples, step-by-step instructions, and useful Python libraries.

🔹 Why Automate Tasks with Python?

Saves time – Eliminate manual and repetitive work
Boosts productivity – Focus on important tasks instead of routine ones
Reduces errors – Automate tasks accurately without mistakes
Easy to learn – Python has beginner-friendly libraries for automation


🔹 Prerequisites

Before we start, make sure you have:
✔ Python installed (Download from python.org)
✔ A basic understanding of Python syntax
✔ An IDE (like VS Code, PyCharm, or Jupyter Notebook)

🎨 Bonus: Enhance Your UI Design with a Free Background Remover

Utilshub’s Background Remover – Make Your UI Assets Stand Out

When designing websites or UI components, high-quality images play a crucial role. However, many designers struggle with removing backgrounds to create clean, professional visuals.

That's where Utilshub’s AI-Powered Background Remover comes in! With just one click, you can:
Remove backgrounds from im
ages instantly
Make UI components look sleek and professional
Create transparent assets for web design
Save time on manual editing

This diagram represents how Python automates tasks like file management, email sending, web scraping, and Excel processing.

          Start
            │
            ▼
   ┌─────────────────┐
   │   User Input   │  (Choose task: Files, Email, Web Scraping, Excel)
   └─────────────────┘
            │
            ▼
   ┌─────────────────┐
   │  Load Python    │  (Run the script)
   └─────────────────┘
            │
            ▼
   ┌────────────────────────┐
   │  Task Execution        │  (Perform the selected automation)
   ├────────────────────────┤
   │ - Rename files         │  
   │ - Send email           │  
   │ - Scrape web data      │  
   │ - Modify Excel files   │  
   └────────────────────────┘
            │
            ▼
   ┌─────────────────┐
   │  Task Completed │  (Save output, send confirmation)
   └─────────────────┘
            │
            ▼
          End

You can create a mind map like this:

        Python Automation
               │
  ┌───────────┴───────────┐
  │                       │
 File Handling      Web Scraping
  │                       │
  ├── Rename Files        ├── Extract Data
  ├── Move Files          ├── Scrape Prices
  ├── Delete Files        ├── Auto-fill Forms
  │                       │
  │                       │
 Email Automation    Excel & CSV Automation
  │                       │
  ├── Send Emails         ├── Read & Edit Data
  ├── Bulk Emails         ├── Generate Reports
  ├── Auto-Responses      ├── Automate Data Entry

🔹 Step 1: Automate File and Folder Management

📌 Example: Rename Multiple Files Automatically

If you have hundreds of files and need to rename them, Python can do it in seconds.

🔹 Install Required Library:

pip install os

🔹 Python Script:

import os

folder_path = "C:/Users/YourName/Documents/files"  # Change this to your folder path
for index, filename in enumerate(os.listdir(folder_path)):
    new_name = f"document_{index}.txt"  # Customize file naming pattern
    old_file = os.path.join(folder_path, filename)
    new_file = os.path.join(folder_path, new_name)
    os.rename(old_file, new_file)

print("Files renamed successfully!")

What it does?

  • Reads all files in a folder

  • Renames them with a sequential number (document_1.txt, document_2.txt, etc.)


🔹 Step 2: Automate Sending Emails with Python

📌 Example: Send Automated Emails Using Python

You can send emails with attachments automatically using Python’s smtplib and email modules.

🔹 Install Required Libraries:

pip install smtplib email

🔹 Python Script:

import smtplib
from email.message import EmailMessage

# Email credentials
EMAIL_ADDRESS = "your_email@gmail.com"
EMAIL_PASSWORD = "your_password"

def send_email():
    msg = EmailMessage()
    msg["Subject"] = "Automated Email from Python"
    msg["From"] = EMAIL_ADDRESS
    msg["To"] = "recipient@example.com"
    msg.set_content("Hello, this is an automated email sent using Python!")

    # Send email
    with smtplib.SMTP_SSL("smtp.gmail.com", 465) as smtp:
        smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
        smtp.send_message(msg)

send_email()
print("Email sent successfully!")

What it does?

  • Logs in to Gmail SMTP

  • Sends an email with a custom subject and message

  • You can modify it to send emails in bulk

🚀 Tip: If you're using Gmail, enable "Less Secure Apps" or use an App Password.


🔹 Step 3: Automate Web Scraping with Python

📌 Example: Extract Data from a Website

Use Python to scrape data from websites and save it into a file.

🔹 Install Required Library:

pip install requests beautifulsoup4

🔹 Python Script:

import requests
from bs4 import BeautifulSoup

url = "https://example.com"  # Replace with the website URL
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")

# Extract all <h1> tags
headings = soup.find_all("h1")

for heading in headings:
    print(heading.text)

What it does?

  • Sends a request to a website

  • Extracts all H1 headings

  • Prints them in the terminal

🚀 Tip: Modify the script to scrape articles, prices, or stock market data!


🔹 Step 4: Automate Excel & CSV File Management

📌 Example: Read and Update an Excel File

Use Python to automate data entry, calculations, and reports in Excel.

🔹 Install Required Library:

pip install openpyxl pandas

🔹 Python Script:

import pandas as pd

# Load Excel file
df = pd.read_excel("sales_data.xlsx")

# Calculate total sales
df["Total Sales"] = df["Quantity"] * df["Price"]

# Save the updated file
df.to_excel("updated_sales_data.xlsx", index=False)

print("Excel file updated successfully!")

What it does?

  • Reads an Excel file

  • Calculates Total Sales (Quantity × Price)

  • Saves the updated file

🚀 Tip: You can automate invoices, reports, and data analysis!


🔹 Conclusion: What’s Next?

Congratulations! 🎉 You’ve learned how to use Python to automate daily tasks like:
✔ Renaming files
✔ Sending emails
✔ Scraping websites
✔ Managing Excel files

🚀 Want to Learn More? Try automating:

💬 What would you like to automate with Python? Comment below and let’s discuss! 🚀🔥

Python

Part 2 of 50

Whether you're a curious newbie entering the world of programming or an experienced developer looking to extend your skill set, this Python Series is your entryway to harnessing Python's potential.

Up next

Yield vs. Return in Python: A Beginner's Guide 2025

Mastering Function Outputs in Python: When to Use yield and return