messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that creates a ZIP archive from a source directory while deduplicating identical files by content. The ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that analyzes a small time series of daily temperatures. Store 10 temperature values in a list, calcula...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a PrefixTrie class in Python to manage a dictionary of lowercase words. Support four operations: insert(word) to add...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that implements both a stack and a queue using Python lists. Create a Stack class with push, pop, and d...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that reads a large UTF-8 log file named \"app.log\" line by line and writes a summary report to \"repor...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python script that performs a simple ETL process on a list of sales records. Each record contains a product name, cate...
[ { "role": "system", "content": "You are an expert Python programming assistant. You write clear, correct, well-documented code that follows the user's instructions." }, { "role": "user", "content": "Create a class that simulates a simple automated trading bot for the finance sector by processing...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a PrefixTrie class to manage a dictionary of lowercase words. Support four operations: insert(word) to add a word, s...
[ { "role": "system", "content": "You are an expert Python programming assistant. You write clear, correct, well-documented code that follows the user's instructions." }, { "role": "user", "content": "Implement a script in Python that analyzes CI/CD pipeline execution logs for a DevOps team. The s...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a Python class `RateLimiter` that enforces throttling using the token bucket algorithm. The class should be initiali...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a plugin-based notification system using abstract base classes. Create an abstract class NotificationChannel with an...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a PrefixTrie class for an autocomplete service. Support insert(word), delete(word), count_prefix(prefix), and top_k(...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that uses recursion to calculate the sum of all numbers in a list of integers. Create a function named ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement an LRUCache class that supports O(1) average-time get(key) and put(key, value) operations using a hash map and a cus...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a simple BloomFilter class in Python for storing strings. The class should use a fixed-size bit array and a configurabl...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Using SQLAlchemy ORM, define two models: Author and Book in a one-to-many relationship where each author can have many books. ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python program that uses a dataclass to represent a book in a small library. Each book should have a title, author, y...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a Python program that computes the sum of prime numbers in the range 1 to 200000 using multiprocessing for CPU-bound...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python script that uses sqlite3 to manage a small task tracker database. The script should create a SQLite database f...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Design an extensible notification system using object-oriented design. Create an abstract base class NotificationChannel with ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python program that uses object-oriented design to model a simple library book tracker. Define a Book class with attr...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a thread-safe plugin registry for serializer classes using both the Singleton and Registry patterns. Create a Serial...
[ { "role": "system", "content": "You are an expert Python programming assistant. You write clear, correct, well-documented code that follows the user's instructions." }, { "role": "user", "content": "Implement a script that processes a CSV export of personal finance transactions and generates a m...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a small event-driven task scheduler in Python. Implement an EventBus class that lets users subscribe callback functions...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python program that demonstrates both the Factory and Builder design patterns for generating notifications. Implement...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python script that sends a simple plain-text email using the smtplib library. The script should define sender email, r...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a function `closest_pair_sum(nums, target)` that takes a sorted list of distinct integers and a target value, and re...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Pydantic model for validating deployment configuration files. The schema must support fields: service_name (non-empty...
[ { "role": "system", "content": "You are an expert Python programming assistant. You write clear, correct, well-documented code that follows the user's instructions." }, { "role": "user", "content": "Write a function that uses Pandas to analyze cloud infrastructure usage logs from a CSV file and ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python script that runs three system commands concurrently using subprocess: one command that prints the current worki...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write an asynchronous Python program that simulates querying three remote services concurrently. Each service should wait for ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python program that loads application settings from a JSON configuration file named \"config.json\". If the file does...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python CLI tool using argparse that reads one or more text files and reports the top N most frequent words across all...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function transform_orders(orders_csv: str, customers_csv: str) -> str that performs an ETL pipeline on two CSV ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Build a command-line Python tool using argparse that reads integers either from a file or from standard input, then prints sum...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that analyzes a daily time series of sales values. Generate a synthetic dataset of 120 days with a tren...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a thread-safe plugin registry for data serializers using a singleton pattern. Create a `SerializerRegistry` class th...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python script that performs a simple ETL pipeline on sales data. The script should read a CSV file named 'sales.csv' c...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python class called LogWindow that works as an iterator over a text file of log entries. Each line in the file has th...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a function `parse_kv_line(line: str) -> dict` that parses a single configuration-style string into a dictionary. The inp...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function `normalize_tracking_url(url: str, extra_params: dict | None = None) -> str` that parses a URL, removes...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "You are given a pandas DataFrame df with columns: order_id, customer_id, region, order_date, ship_date, status, quantity, unit...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python program that demonstrates the Strategy Pattern for calculating shipping costs. Define a common interface for s...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a function `k_smallest_pairs(nums1, nums2, k)` that returns the `k` pairs `(a, b)` with the smallest sums, where `a` com...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Given a pandas DataFrame named df containing sales data with columns 'date', 'store', 'category', 'units_sold', and 'unit_pric...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function normalize_and_filter_urls(urls, allowed_domains, required_params) that processes a list of URL strings...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python program using NumPy that stores the daily temperatures for one week in a 1D array. The program should print th...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that defines a function `min_path_sum(grid)` which takes a non-empty 2D list of positive integers and r...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python script that migrates customer records from an old JSON export to a new schema. The input is a list of dictionar...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that processes a list of customer orders using list comprehensions and basic list operations. Each orde...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python TCP echo server that listens on 127.0.0.1 port 5000, accepts one client at a time, receives text messages, and ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function `count_expression_ways(nums, target)` that uses recursion with memoization to count how many different...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python script that migrates user records from an old schema to a new schema. The script should read a list of dictiona...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Pydantic-based validation layer for a payment API request. Define a model for a payment payload with these fields: pa...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that creates a ZIP archive named backup.zip from all .txt files in the current folder. The program shou...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a function `find_overlapping_work_hours(events_a, events_b, tz_a, tz_b, target_tz)` that receives two lists of calendar ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that analyzes a list of customer support ticket records using the collections module. Each ticket is re...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that creates a deterministic .tar.gz archive from a source directory. The program must recursively incl...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python script that asks the user for a file path and prints the directory name, base file name, file name without exte...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a small Python module for managing shopping cart totals and write pytest unit tests for it. Implement a function `calcu...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that demonstrates basic protocol buffer handling. Define a simple Person message dynamically with field...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a function `normalize_tracking_url(url: str, allowed_params: set[str] | None = None) -> str` that parses a URL and retur...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that sends a simple plain-text email using the smtplib module. The program should define sender email, ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python script that performs an idempotent data migration from a legacy users table to a new users table in SQLite. The...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python script that migrates customer records from an old CSV file to a new CSV file. The input file is named 'old_cust...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function `load_app_config(path)` that loads a JSON configuration file for an application. The function should: ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a small plugin-based text processing system in Python. Define a PluginManager class that can register named plugins, en...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a Python function `lazy_filter_map(items, predicate, transform, limit=None)` that lazily processes an iterable. It s...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a simple plugin architecture in Python for a text processing app. Define a base Plugin class with a process(text) metho...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a small configuration validation module. Create a custom exception hierarchy rooted at ConfigError, with InvalidConf...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python program using matplotlib to visualize average monthly temperatures. Use two lists: one for the 12 months from ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Given an undirected tree with n nodes labeled from 0 to n-1 and a list of n-1 edges, write a function `tree_diameter(n, edges)...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python script that loads application configuration from environment variables. It should read APP_HOST, APP_PORT, APP_...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a function `min_palindrome_cuts(s: str) -> int` that returns the minimum number of cuts needed to split a string into su...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that demonstrates lazy evaluation by processing a list of numbers with generators. Create a function th...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a function `parse_log_line(line: str) -> dict` that parses a single application log line into structured data. Each log ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function load_app_config(path: str, env_prefix: str = \"APP_\") -> dict that loads a JSON configuration file, v...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python script that runs a shell command provided as a list of arguments, captures stdout and stderr separately, enforc...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a Trie (prefix tree) class in Python to manage a dictionary of lowercase English words. Support these operations: in...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement an advanced LRU cache class in Python named LRUCache with O(1) average-time get and put operations. The cache should...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python script that defines a small REST API client using the requests library. The client should fetch a list of users...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function `verify_manifest(base_dir, manifest)` that validates file integrity for a directory tree using SHA-256...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function that analyzes a list of web server log entries represented as dictionaries with keys 'ip', 'endpoint',...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that works with a shopping list using list comprehensions and basic list operations. Start with a list ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a context manager class called Timer that measures how long a block of code takes to run. When entering the with block,...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that creates a ZIP archive from all .txt files in the current folder. The program should search the cur...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement an LRUCache class in Python with a fixed capacity. Support get(key) and put(key, value) in O(1) average time. When t...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python program that uses an abstract base class called Shape with an abstract method area(). Then implement two subcl...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python script that sends a simple plain-text email using the built-in smtplib library. The script should ask the user ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a custom context manager class called Timer that measures how long a block of code takes to run. The class should accep...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a small Python module for a shopping cart. Write a function named calculate_total(prices) that takes a list of item pri...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python program that defines a singly linked list and implements an operation to append values to the end of the list....
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python script that uses matplotlib to visualize monthly sales data for two products over one year. Plot both products...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python script that migrates user records from an old schema to a new schema. The input is a list of dictionaries where...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that manages a small shopping cart using list comprehensions and basic list operations. Start with a li...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that simulates calling an unreliable service. Create a function that randomly succeeds or fails. Then i...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python command-line tool using argparse that accepts a required text argument and an optional --upper flag. The progr...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python program that implements a simple Binary Search Tree (BST). Define a Node class and a BinarySearchTree class wi...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python script that performs an idempotent data migration from a legacy SQLite database to a new SQLite database. The l...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function `render_template(template: str, context: dict) -> str` that renders a mini text template language. Rep...