200-901 · Question #168
What is used in JSON to represent a Python Tuple?
The correct answer is B. Array. In JSON, a Python Tuple is represented by an Array, which is an ordered collection of values enclosed in square brackets.
Question
What is used in JSON to represent a Python Tuple?
Options
- AObject
- BArray
- CDict
- DCollection
How the community answered
(46 responses)- A7% (3)
- B87% (40)
- C2% (1)
- D4% (2)
Why each option
In JSON, a Python Tuple is represented by an Array, which is an ordered collection of values enclosed in square brackets.
A JSON Object represents a Python dictionary (dict) or similar key-value mapping, not an ordered sequence like a tuple.
A Python Tuple is an ordered, immutable sequence of elements. In JSON, the closest equivalent for an ordered sequence is an Array, which represents an ordered list of values and is denoted by square brackets `[]`.
A Dict in Python is represented as a JSON Object, which is an unordered collection of key-value pairs.
"Collection" is a general term and not a specific JSON data type.
Concept tested: JSON data types and Python data structure mapping
Source: https://docs.python.org/3/library/json.html#json-types
Topics
Community Discussion
No community discussion yet for this question.