nerdexam
CiscoCisco

300-435 · Question #71

300-435 Question #71: Real Exam Question with Answer & Explanation

The correct answer is B: a dictionary. The most logical Python object to store a JSON response from a web service is a dictionary, as JSON objects directly map to Python dictionaries.

Network Automation Foundation

Question

A web service returns a JSON object to your Python script. What is the most logical object in which to store the JSON response?

Options

  • Aan integer
  • Ba dictionary
  • Ca tuple
  • Da string
  • Ea list

Explanation

The most logical Python object to store a JSON response from a web service is a dictionary, as JSON objects directly map to Python dictionaries.

Common mistakes.

  • A. An integer can only hold a single numerical value, which is insufficient for a structured JSON object.
  • C. A tuple is an immutable ordered sequence and does not naturally represent the key-value structure of a JSON object.
  • D. A string can hold the raw JSON text, but it must be parsed to become an accessible Python data structure, making it less logical for direct storage and manipulation.
  • E. A list is an ordered sequence of items, whereas a JSON object is an unordered collection of key-value pairs, which is better represented by a dictionary.

Concept tested. JSON to Python data type mapping

Reference. https://docs.python.org/3/library/json.html

Topics

#JSON#Python Data Structures#API Interaction

Community Discussion

No community discussion yet for this question.

Full 300-435 PracticeBrowse All 300-435 Questions