QuestionQ17

Controller-Based Network Automation

Question Image

Refer to the exhibit. A Python script has been created that calls the Cisco SD-WAN vManage Device Inventory API to retrieve the list of vEdges. The JSON data returned has been converted into a Python dictionary and assigned to a variable named d. A portion of the JSON is shown in the exhibit.

Which code completes the expression hostname= to access the hostname?

Explanation

The exhibited JSON has "data" as the top-level key, whose value is a list; the first item in that list (index 0) is a dictionary containing the key "host-name". To retrieve this value in Python, you must use square-bracket indexing with the keys given as quoted strings, in the correct nested order: d["data"][0]["host-name"]. This matches standard Python dictionary/list access syntax, where dictionary keys must be quoted strings and list elements are accessed by integer index using square brackets. Omitting quotes around keys, using parentheses instead of brackets, or reversing the key order/using curly braces all produce invalid or incorrect Python syntax for this data structure.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!