🌍 Python · flashcards

Python Weather App Project Flashcards

51 question-and-answer cards covering Weather App Project as it is examined in Python. 24 of them are printed below, taken from across the deck — no signup, no paywall on the preview.

51Cards in deck
24Free preview
16Syllabus topics
~127Chars per answer
FreePrice

24 sample cards from the Weather App Project deck

Sampled from the end of the deck, so these are different cards from the ones shown on the syllabus page.

  1. In argparse, how do you attach a help description to an argument?

    Pass the `help` keyword, e.g. `parser.add_argument("city", help="Name of the city to look up")`. It appears in the `-h` output.

  2. Write a basic `requests` call that sends a GET request to a weather API with query parameters.

    `import requests` `response = requests.get(url, params={"q": city, "appid": key, "units": "metric"})`. The `params` dict is URL-encoded into the query string.

  3. Why is passing query data via the `params` argument preferable to manually building the URL string?

    `requests` automatically URL-encodes the values (handling spaces, special characters) and keeps the code readable and less error-prone.

  4. What is the recommended way to set a timeout on a weather API request, and why?

    Pass `timeout`, e.g. `requests.get(url, params=..., timeout=10)`. It prevents the program from hanging indefinitely if the server does not respond.

  5. What does the HTTP status code 200 indicate in an API response?

    200 OK means the request succeeded and the response body contains the requested data.

  6. What do HTTP status codes 401 and 404 typically mean for a weather API request?

    401 Unauthorized means an invalid or missing API key; 404 Not Found usually means the requested city/resource does not exist.

  7. What does HTTP status code 429 indicate, and how should a CLI react?

    429 Too Many Requests means you exceeded the rate limit. The CLI should inform the user and optionally back off and retry later.

  8. In what format do most weather APIs return data, and how do you parse it with `requests`?

    JSON. With `requests`, call `response.json()` to deserialize the body into a Python dictionary/list.

  9. After calling `response.json()`, how would you extract a nested temperature value from `{"main": {"temp": 21.5}}`?

    `data = response.json(); temp = data["main"]["temp"]`. Indexing the nested dict yields `21.5`.

  10. What method on a `requests` response object raises an exception for HTTP error status codes?

    `response.raise_for_status()`. It raises `requests.HTTPError` for 4xx and 5xx responses, letting you handle failures explicitly.

  11. Why is it safer to use `dict.get("key")` instead of `dict["key"]` when reading parsed API data?

    `get` returns `None` (or a default) if the key is missing instead of raising a `KeyError`, making the code more robust to unexpected response shapes.

  12. What is the formula to convert a temperature from Kelvin (returned by some APIs) to Celsius?

    $T_{\\text{C}} = T_{\\text{K}} - 273.15$, where $T_{\\text{K}}$ is the temperature in Kelvin.

  13. What is the formula to convert a temperature from Celsius to Fahrenheit?

    $T_{\\text{F}} = \\frac{9}{5}\\,T_{\\text{C}} + 32$, where $T_{\\text{C}}$ is degrees Celsius.

  14. How can you format a floating-point temperature to one decimal place in a Python f-string?

    Use a format spec, e.g. `f"{temp:.1f}"`. For `temp = 21.567` this yields `"21.6"`.

  15. When formatting CLI output, why is alignment and labeling (e.g. "Temperature: 21.5C") important?

    It makes the data human-readable and scannable, clearly associating each value with what it represents instead of dumping raw JSON.

  16. What is the simplest way to display formatted weather results to the user in a CLI program?

    Use the built-in `print()` function to write the formatted strings to standard output (stdout).

  17. What is the difference between printing to stdout and stderr, and which should errors use?

    stdout carries normal program output; stderr carries diagnostics and errors. Print error messages to stderr, e.g. `print(msg, file=sys.stderr)`, so they can be separated from data.

  18. Why is testing a CLI with different inputs (valid city, invalid city, missing arguments) important?

    It verifies the happy path and confirms the program handles edge cases and errors gracefully instead of crashing, improving reliability.

  19. Give examples of edge-case inputs you should test in a weather CLI.

    City names with spaces ("New York"), misspelled/nonexistent cities, empty input, special characters, different unit flags, and a missing/invalid API key.

  20. Which Python construct is used to catch and handle runtime errors gracefully?

    A `try` / `except` block. Code that may fail goes in `try`, and the handling logic goes in `except`, optionally catching specific exception types.

  21. Which exception should you catch to handle network failures when using the `requests` library?

    `requests.exceptions.RequestException` (the base class), or specific subclasses like `ConnectionError` and `Timeout`.

  22. What is a good practice for the exit code of a CLI when an error occurs?

    Exit with a non-zero status, e.g. `sys.exit(1)`. A zero exit code signals success; non-zero lets scripts and shells detect the failure.

  23. What key elements should usage instructions for a CLI tool include?

    Installation steps, how to set the API key, the command syntax with all arguments/flags, default values, and the expected output format.

  24. Why should documentation include concrete usage examples, and give one for a weather CLI?

    Examples let users copy a working command and see expected results immediately. Example: `python weather.py "New York" --units imperial` shows the current weather in Fahrenheit.

What this deck covers

The Weather App Project deck follows the Python Weather App Project syllabus — 7 chapters and 16 topics — so questions land on material that is genuinely examinable rather than trivia around it. That works out to roughly 7.3 cards per chapter.

Answers are written to be recallable, not just readable — averaging about 127 characters, which is long enough to carry the reasoning and short enough to say out loud.

A deck like this earns its keep on the second and third pass. Read the syllabus first so you know the shape of the subject, then use the cards to find the specific facts that have not stuck.

Weather App Project flashcards FAQ

How many Weather App Project flashcards are in this Python deck?

51 cards. This page previews 24 of them, sampled evenly across the deck so you can judge the difficulty before installing anything.

Are these Python flashcards free?

Yes. The preview here is free to read with no signup, and the full 51-card deck is free inside the Examius app.

What do the Weather App Project cards cover?

They follow the Python Weather App Project syllabus — 7 chapters and 16 topics — so the questions track what is actually examinable.

How should I use these flashcards?

Read the syllabus first so you know the shape of the subject, then drill the deck. Examius schedules each card with spaced repetition, so cards you keep missing come back sooner and ones you know drift further apart.