Courseiva

200-901 Software Development and Design Practice Question

A developer is building a Python script that calls a REST API which returns a JSON payload containing a list of interfaces. The script must parse the response and extract the 'name' field from each interface object. Which approach correctly uses the requests library to parse the JSON and iterate over the interfaces?

⚠ Common exam trap

It's easy for candidates to confuse the Response object with its JSON content, or forgetting to call .json() as a method, leading to type errors when trying to index the response.

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

✓

response = requests.get(url); interfaces = response.json(); for intf in interfaces['interfaces']: print(intf['name'])

The requests library's Response object provides a .json() method that deserializes the JSON response body into Python objects. After calling .json(), the result is typically a dictionary or list that can be indexed and iterated. Using response.json() is the idiomatic way to parse JSON in requests, and the subsequent iteration extracts the 'name' field from each interface dictionary.

Answer analysis

Option-by-option breakdown

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

  • ✗

    response = requests.get(url); interfaces = json.loads(response); for intf in interfaces['interfaces']: print(intf['name'])

    Why it's wrong here

    This fails because json.loads() expects a string or bytes-like object, but response is a Response object. Passing the Response directly raises a TypeError. The correct approach is to use response.json() or json.loads(response.text). The rest of the logic is syntactically valid but the parsing step is wrong.

  • ✗

    response = requests.get(url); interfaces = response.json; for intf in interfaces['interfaces']: print(intf['name'])

    Why it's wrong here

    This fails because response.json is a method reference, not the parsed data. The code assigns the method itself to interfaces without calling it, so interfaces is a bound method object. Subscripting it with ['interfaces'] raises a TypeError. The developer must call response.json() with parentheses to obtain the parsed JSON.

  • ✓

    response = requests.get(url); interfaces = response.json(); for intf in interfaces['interfaces']: print(intf['name'])

    Why this is correct

    This is correct because requests.get() returns a Response object, and calling .json() on it parses the JSON body into Python data structures. If the payload has a top-level key 'interfaces' containing a list of dictionaries, indexing with ['interfaces'] and iterating yields each interface dict, from which ['name'] extracts the desired field.

  • ✗

    response = requests.get(url); interfaces = response.text; for intf in interfaces['interfaces']: print(intf['name'])

    Why it's wrong here

    This fails because response.text returns the raw response body as a string, not a parsed Python object. Attempting to subscript a string with ['interfaces'] raises a TypeError since strings only accept integer indices. The developer must parse the JSON first, typically with response.json(), to work with dictionaries and lists.

About these practice questions

One of 975 original 200-901 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.