Maintenance

Site is under maintenance — quizzes are still available.

Go to quizzes
Sponsored Reserved space — layout preview until AdSense is connected

Reference library

Automation & scripting

CLI tools, scheduled jobs, filesystem tasks, and glue scripts that save time.

2 matches
Sponsored Reserved space — layout preview until AdSense is connected
Automation & scripting easy

How to Generate a QR Code in Python

Generate a QR code image from a URL string using the qrcode library and save it as a PNG file.

qrcode automation image-generation
Python
import qrcode

# Data to encode
data = "https://www.example.com"

# Create QR code instance
qr = qrcode.QRCode(
    version=1,
    error_correction=qrcode.constants.ERROR_CORRECT_L,
    box_size=10,
    border=4,
)

# Add data to QR code
qr.add_data(data)
qr.make(fit=True)

# Create an image from the QR code
img = qr.…
2 0 Open
Automation & scripting easy

How to Resize Hundreds of Images in Batch with Python

Resize every image in a folder to a target size using Pillow, creating a new subfolder for processed files.

image processing batch processing pillow
Python
import os
from PIL import Image

def resize_images_in_batch(directory, output_size=(800, 600)):
    if not os.path.exists(directory):
        print(f"Directory {directory} does not exist.")
        return
    output_dir = os.path.join(directory, "resized")
    os.makedirs(output_dir, exist_ok=True)
    for filename in…
2 0 Open

Browse by section

Each section groups closely related Python snippets.

Automation & scripting — Python code examples

What you will find here

This page collects automation & scripting snippets — short, copy-ready Python you can paste into our free online IDE and run without installing anything. Each sample includes a plain-English explanation and the full source code.

Samples vs tutorials and challenges

Samples are quick reference — one concept per page. For step-by-step teaching, use our Python tutorials. To test yourself, try quizzes or coding challenges. Clean up style with the Python formatter.