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": "Create a Python module that models a small event scheduling system using dataclasses and advanced type hints. Define an immuta...
[ { "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 class called LRUCache that stores a limited number of key-value pairs using the Least Recently Used policy. 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 scrapes all product cards from https://books.toscrape.com/, following pagination across every catal...
[ { "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 `extract_valid_contacts(text)` that uses regular expressions to scan a block of text and return 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": "Write a function `remove_duplicates(head)` that takes the head of a singly linked list sorted in non-decreasing order and remo...
[ { "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 to enter a system command, runs it safely using the subprocess module without invokin...
[ { "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 a sliding time window. The class should be initialized wit...
[ { "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 Flask webhook handler for a payment provider. Create a POST /webhook endpoint that reads the raw request body, ver...
[ { "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 reusable preprocessing pipeline for a tabular machine learning dataset. Given a pandas DataFrame `df` and the name of ...
[ { "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 asks the user to enter five test scores as numbers. Store the scores in a list, then calculate 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 program that simulates a simple batch processing pipeline for customer orders. The program should take a list o...
[ { "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 accepts a list of file paths and converts each one to an absolute, normalized path, removing redund...
[ { "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 asks the user to enter 5 test scores as numbers. The program should calculate and display the mean...
[ { "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 a Caesar cipher toolkit. Create two functions: one to encrypt a message by shifting alp...
[ { "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) -> str` that parses a URL, removes common tracking query parameters ...
[ { "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 plugin-based notification system using abstract base classes. Define an abstract base class `NotificationCha...
[ { "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 starts a simple TCP server on localhost port 5000. The server should wait for one client connectio...
[ { "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 `top_k_error_sequences(logs, k)` that analyzes a list of application log records and returns the `k` most 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": "Create a small event-driven notification system in Python. Implement an EventBus class that lets users subscribe callback func...
[ { "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 program that demonstrates both the singleton and registry patterns. Implement a Logger class as a single...
[ { "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 `analyze_access_logs(records)` that processes a list of access log tuples in the form `(user_id, resource, ac...
[ { "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 `parse_log_entries(text: str) -> list[dict]` that uses regular expressions to parse a multi-line appli...
[ { "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 binary file named input.bin and creates a new binary file named output.bin. The program sh...
[ { "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 plugin architecture in Python for a text-processing pipeline. Create a PluginManager that supports dynam...
[ { "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 simple BloomFilter class in Python for checking possible membership of strings. The class should be initialized wi...
[ { "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 manages a simple machine learning experiment tracker for an AI platform. 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": "Implement a configuration loader for a payment service. Create a custom exception hierarchy rooted at ConfigError with these 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 Python script that sends an email with both plain-text and HTML content using smtplib. Read SMTP host, port, username,...
[ { "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 small Python module that defines a function `merge_unique_sorted(a, b)` which takes two sorted lists of 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 program that converts a list of user records between JSON and CSV serialization formats. Implement two function...
[ { "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 fetch_all_users(base_url, token) that acts as a robust REST API client for a paginated endpoint at GET...
[ { "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 for a small to-do list manager that lets the user enter several tasks with priority numbers, sorts 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 asks the user for a directory path, checks whether the directory exists, and then lists all files ...
[ { "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 typed configuration registry using dataclasses. Define an immutable dataclass AppConfig with fields: name (str), 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 class called LRUCache that stores a fixed number of key-value pairs using the Least Recently Used (LRU) rule. 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": "Given a pandas DataFrame named df containing sales data with columns 'date', 'region', 'product', '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": "Implement a Python function serialize_record(record: dict, format_name: str) -> bytes and deserialize_record(data: bytes, form...
[ { "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 plain-text email to one or more recipients using smtplib. The script should define a reusab...
[ { "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. The program should define a function create_zip_arc...
[ { "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 lazy round-robin merge generator for multiple input iterables. Write a function `round_robin(*iterables)` that yie...
[ { "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": "Can you create a function in Python for a finance-sector fraud detection system that analyzes a 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 program that calculates the total travel distance along a route defined by a list of GPS coordinates. 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": "Create a small Python module with a function called is_even(number) that returns True if an integer is even and False otherwis...
[ { "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 batch processing pipeline that reads a list of job dictionaries, validates required fields (id, payload, retries),...
[ { "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 simple Protocol Buffers message type at runtime with fields `id` (int32) and `name` (stri...
[ { "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_pal_partition(s: str) -> int` that returns the minimum number of cuts needed to split a string into subs...
[ { "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 analyze_orders(orders) that processes a list of order records using list comprehensions and list opera...
[ { "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 reads a JSON file named input.json containing a list of sales records. Each record has the fields: ...
[ { "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 a text file and counts lines, words, and characters. The program should acc...
[ { "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 `convert_ndjson_to_grouped_msgpack(input_path, output_path)` that reads a newline-delimited JSON (...
[ { "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 a method to append integers to the end of the list. 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": "Implement an advanced configuration-merging utility using dataclasses and type hints. Define a frozen dataclass AppConfig 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": "Write a Python function `render_invoice(template, data)` that renders a text invoice from a template string using named placeh...
[ { "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": "Develop a module that analyzes CI/CD pipeline run logs from CSV files using Python and Pandas to ...
[ { "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 generates a synthetic monthly sales dataset for three product categories over 24 months, computes ...
[ { "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 class MaxQueueStackProcessor that processes a sequence of commands using both a stack and a queue, each supporting...
[ { "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 configuration model for a web service using advanced property and descriptor patterns. Implement a reusable des...
[ { "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 asks the user to enter a sentence, then uses regular expressions to find and print all email addre...
[ { "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 simple text editor using the Command pattern. Create command classes for inserting text and deleting the last N ch...
[ { "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 multipart email with both plain-text and HTML bodies using smtplib and email.message.EmailM...
[ { "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 manager for a data processing app using both the singleton and registry patterns. Create a singleton class ...
[ { "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 module that defines a function normalize_username(name: str) -> str and a set of pytest unit tests. The functio...
[ { "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 reusable memoization decorator using functools that caches function results with a bounded LRU cache and preserves...
[ { "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 df with columns: order_id, customer_id, order_date, region, product, quantity, unit_price, and status...
[ { "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 preprocesses a machine learning dataset using pandas and scikit-learn. The script should build a 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 small Python program that simulates web framework routing patterns. Define a Router class that lets you register URL ...
[ { "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 product catalog. Given a list of products where each product is represented as a 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": "Given a list of positive integers nums and an integer target, write a function count_target_expressions(nums, target) that ret...
[ { "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 task queue using a min-heap. First read an integer n, then read n commands. Each command...
[ { "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 WordFilter that uses a trie-based prefix tree approach to support efficient word dictionary operation...
[ { "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 decode_people(blob: bytes) -> list[dict] that parses a binary Protocol Buffers payload representin...
[ { "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 URL router similar to those used in web frameworks. Create a Router class with an add_route(method, pattern,...
[ { "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 `sum_nested(data)` that recursively calculates the sum of all integers inside a nested list structure....
[ { "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 scans a given directory recursively and creates a report of all .txt files it contains. For each 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 defines a Pydantic model for validating a user registration payload. The payload must include use...
[ { "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_largest_sum(nums, k)` that uses heap operations to return the sum of the `k` largest integers in a list. 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": "Write a Python function render_template(template: str, context: dict) -> str that renders a mini template language. Replace pl...
[ { "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 both a Stack and a Queue using Python lists. The Stack should support 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": "Create a Pydantic v2 model for validating deployment configuration data. The input contains: app_name (string, 3-30 chars, low...
[ { "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 PrefixDictionary class using a trie (prefix tree) to support efficient word storage and prefix queries. The class ...
[ { "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 `df` with columns `customer_id`, `order_id`, `order_date`, `region`, and `amount`, write a function `...
[ { "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 decodes a Protocol Buffers message from raw bytes without using any protobuf library. The message...
[ { "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 asks the user to enter two whole numbers and then prints their division result. Use error handling...
[ { "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 fetching data from three different APIs. Create an async function fetch_da...
[ { "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 `caesar_crack(ciphertext)` that performs frequency-analysis-based cracking of a Caesar cipher on upper...
[ { "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 `merge_busy_intervals(events)` that takes a list of calendar events and returns merged busy time inter...
[ { "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 async/await basics by simulating three online tasks: fetching a user profile, loading...
[ { "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 takes a block of text and extracts all valid email addresses using regular expressions. Return a ...
[ { "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 class LRUCache that supports an integer capacity and provides O(1) average-time get(key) and put(key, value) opera...
[ { "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 GET request to the public JSONPlaceholder REST API endpoint https://jsonplaceholder.typicod...
[ { "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 TCP port scanner in Python that accepts a host and a list of ports, attempts to connect to each port with a short time...
[ { "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 template rendering utility in Python. Write a function `render_template(template: str, context: dict) -> str...
[ { "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 `extract_config_blocks(text: str) -> list[dict]` that uses regular expressions to parse a configuration-like ...
[ { "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 classroom attendance record using dictionaries and sets. Create a dictionary 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 compares threading and multiprocessing for a CPU-bound task. Create a function that counts how man...
[ { "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 uses the requests library to fetch a list of users from the public REST API at https://jsonplacehol...
[ { "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 `sliding_window_averages(readings, size)` that takes an iterable of numeric sensor readings and returns a lis...
[ { "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 middleware pipeline in Python. Create a function build_pipeline(middlewares, handler) that composes 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": "Implement an LRUCache class in Python that supports a fixed capacity and provides O(1) average-time get(key) and put(key, valu...
[ { "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 execute. The class should accept a...