Courseiva

200-901 Infrastructure and Automation Practice Question

Exhibit

Refer to the exhibit.

{
    "response": [
        {
            "hostname": "Core-Router",
            "managementIpAddress": "10.1.1.1",
            "platformId": "ISR4451-X",
            "serialNumber": "F0C1234A5B6",
            "lastUpdated": "2023-11-28T15:30:00.000+00:00"
        }
    ],
    "version": "2.0.0"
}

A developer uses the Cisco DNA Center API to retrieve device inventory. The JSON response is shown. Which Python code snippet correctly extracts the serial number?

⚠ Common exam trap

The trap here is that candidates mistakenly treat the JSON response as a flat dictionary or forget that the 'response' value is a list, leading them to omit the list index and incorrectly access 'serialNumber' directly from '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

✓

data['response'][0]['serialNumber']

The JSON response from the Cisco DNA Center device inventory API returns a list of devices under the 'response' key, and each device is a dictionary. The serial number for the first device is accessed by indexing into the list with [0] and then retrieving the 'serialNumber' key from that 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.

  • ✓

    data['response'][0]['serialNumber']

    Why this is correct

    The DNA Center inventory response nests device records in a 'response' array, so indexing [0] selects the first device and ['serialNumber'] retrieves its serial value. This matches the JSON structure shown, unlike snippets that omit the array index or use incorrect key names.

  • ✗

    data['serialNumber']

    Why it's wrong here

    The response is a JSON array of device objects, so subscripting it with a string key raises a TypeError rather than returning a serial number. It is tempting because serialNumber is a genuine field name, and this syntax would be correct if the top-level JSON were a single device object instead of a list.

  • ✗

    data['response']['serialNumber']

    Why it's wrong here

    The response nests device records in a list, so indexing serialNumber directly on the response object raises a TypeError; the code must iterate the list and read each record's field. It is tempting because serialNumber is a real key, but only inside each list element.

  • ✗

    data[0]['serialNumber']

    Why it's wrong here

    Indexing the array with [0] returns only the first device's record, so any additional inventory entries are silently ignored. It is tempting because the sample response may happen to contain a single device, where data[0] and iteration coincide; the correct snippet iterates over every element of the list.

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 by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

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.