Courseiva

200-901 Understanding and Using APIs Practice Question

A developer is writing a script that calls a REST API returning JSON. The script uses the Python requests library and must detect when the server responds with a 429 Too Many Requests status. Which expression correctly evaluates the status code?

⚠ Common exam trap

Candidates often confuse the boolean ok flag or the textual reason string with the numeric status code that actually identifies a 429.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

if response.status_code == 429:

The requests library exposes the numeric HTTP status through the status_code attribute, so comparing it to 429 is the correct way to detect rate limiting. Attributes like ok and reason serve different purposes and do not carry the integer code. Checking status_code enables the script to trigger backoff and honor Retry-After headers appropriately.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    if response.reason == 429:

    Why it's wrong here

    The reason attribute is the human-readable phrase such as "Too Many Requests", a string, not an integer. Comparing a string to 429 is always False in Python, so the branch would never execute. Developers sometimes mistake reason for the numeric code, but it carries only the textual status description.

  • ✗

    if response.ok == 429:

    Why it's wrong here

    The ok attribute is a boolean that is True for status codes below 400 and False otherwise. Comparing a boolean to the integer 429 is always False, so this condition never triggers. It confuses a truthiness flag with the numeric status code and would silently skip rate-limit handling.

  • ✗

    if response.headers["Status"] == 429:

    Why it's wrong here

    HTTP status is conveyed in the status line, not a response header named Status. Accessing that key would typically raise a KeyError. Even if a server added such a header, comparing a string header value to an integer would still fail, so this approach is doubly incorrect for detecting a 429.

  • ✓

    if response.status_code == 429:

    Why this is correct

    The status_code attribute of a requests Response holds the integer HTTP status. Comparing it to 429 directly identifies the rate-limit condition. This is the canonical check and works regardless of the response body or headers, making it the reliable way to branch into backoff logic.

About these practice questions

This 200-901 question is part of Courseiva's 975-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Cisco exam blueprint

This 200-901 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 200-901 exam.