Write a Python script that performs the following tasks: Fetch Data: Asynchronously…
- User
Write a Python script that performs the following tasks: Fetch Data: Asynchronously fetch user data from https://jsonplaceholder.typicode.com/users. Asynchronously fetch to-do items from https://jsonplaceholder.typicode.com/todos. Process and Combine Data: For each user, calculate the percentage of their to-do items that are marked as "completed". Filter this list to include only users who live in a suite (address.suite contains "Suite"). Generate a Report: From the filtered list, identify the top 3 users with the highest completion percentage. Generate a summary report in Markdown format that lists these top 3 users. The report should include the user's name, company name, city, and their to-do completion percentage, formatted to two decimal places. Constraints and Requirements: Language: Python 3.9+ Libraries: Use the standard asyncio library for asynchronous requests and aiohttp for the HTTP client. Do not use the requests library. Error Handling: The script must gracefully handle potential network errors (e.g., timeouts, non-200 status codes) and JSON decoding errors. If an API call fails, it should print an informative error message to stderr and exit gracefully. Code Quality: The code must be well-structured, using functions to separate concerns (e.g., a function for fetching, a function for processing). It should be readable and include type hints and a docstring for each function. Output: The final output printed to standard output should be only the Markdown report.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.