Week 13 Assignment
1. Overview
Welcome to the real world of software development! Up until now, your programs have lived in isolation, using only the data you typed in or read from a local file. This week, you will break those walls.
Your Mission: Choose a public API, fetch live data from the internet, and build a useful or entertaining console application that processes that data.
2. Instructions
Step 1: Choose Your Data Source
Visit the Public APIs Repository as a starting point. Browse the categories (Animals, Finance, Games, Weather, etc.) and pick one or more APIs that interest you. You are not limited to this list - you may use any public API you find online.
Advice on Choosing:
- Beginner: Look for APIs that say
Auth: No. These are the easiest to use (e.g., Cat Facts, CoinGecko, Agify). - Advanced: You may choose APIs that require an API Key (
Auth: apiKey). You will need to sign up for their service to get a key. - Warning: Test the URL in your browser first! Some public APIs go offline or break. Ensure you see JSON data in your browser before writing code.
Step 2: Define Your Application
Don’t just print raw data. Your program must solve a problem or provide value.
- Bad: Fetch a list of books and print them.
- Good: Ask the user for a genre, fetch books, filter out ones published before 2000, and save the top 5 to a file.
Step 3: Implementation
Write your Python program. It must meet the technical requirements listed below.
3. Technical Requirements (The “Must-Haves”)
To receive a passing grade, your program must include:
- External Library: You must use the
requestslibrary. - User Interaction: The program must take input from the user (e.g., asking for a search term, a category, or a number of results) and use that input to modify the API request or the data display.
- Data Processing: You cannot simply print the JSON response. You must:
- Parse the JSON into a Dictionary or List.
- Process the data in some way (Sort it, Filter it, Calculate an average, Search through it).
- Error Handling: You must implement
try/exceptblocks to handle:- Network errors (No internet connection).
- API errors (404 Not Found, 500 Server Error).
- Invalid user input.
- Clean Output: The final result displayed to the user must be formatted and readable (not a raw dictionary dump).
Grading Rubric (Total: 100 Points)
| Category | Criteria | Points |
|---|---|---|
| Functionality & Complexity | (40 pts) | |
| Program runs without crashing. | 10 | |
| Successfully connects to an API and retrieves data. | 10 | |
| Data Processing: The program performs logic on the data (sorting, filtering, or calculating) rather than just displaying raw results. | 20 | |
| User Experience (UX) | (20 pts) | |
| Program handles User Input effectively (e.g., search queries, menu selection). | 10 | |
| Output is formatted cleanly and is easy to read (no raw JSON/brackets printed). | 10 | |
| Code Quality | (25 pts) | |
Modularity: Code is organized into functions (e.g., get_data(), process_data(), display_results()). |
15 | |
Variable Naming: Variables have descriptive names (user_list vs u, price vs p). |
10 | |
| Error Handling | (15 pts) | |
Implements try/except for network requests (handling connection errors). |
10 | |
| Handles invalid JSON or empty results gracefully (e.g., “No results found” instead of crashing). | 5 |
Bonus Points (Optional)
- +5 Points: Save the processed data to a file (
.txt,.csv, or.json). - +5 Points: Use two different APIs and combine the data (e.g., Get a country from one API and its flag image from another).
This content will be available starting December 23, 2025.