This quiz checks what you know about JSON handling in Python. JSON is a popular format for storing and exchanging data, and Python makes it easy to read, write, and work with it!
Question 1
What is the full form of JSON?
Java Source Object Notation
Javascript Object Notation
Java Structuring Over Network
Jupyter Script Object Notation
Question 2
Which module in Python provides support for handling JSON data?
pickle
xml
json
data
Question 4
What does json.dumps() return?
A file object
A dictionary
A JSON-formatted string
A list
Question 5
In the below code, what does indent=4 do?
json_object = json.dumps(dictionary, indent=4)
Sets max nesting level
Adds 4 blank lines
Formats JSON output with 4 spaces indentation
Adds 4 new dictionaries
Question 6
Which method is used to directly write a Python dictionary to a JSON file?
json.write()
json.dumps()
json.dump()
json.insert()
Question 7
What is the output of this code if sample.json contains valid JSON?
with open('sample.json', 'r') as file:
data = json.load(file)
print(type(data))
<class 'str'>
<class 'list'>
<class 'dict'>
<class 'json'>
Question 8
Which of the following methods is used to deserialize JSON data from a file into a Python object?
json.deserialize()
json.open()
json.read()
json.load()
Question 9
What’s the difference between json.dumps() and json.dump()?
No difference
dumps() writes to a file, dump() returns a string
dump() writes to a file, dumps() returns a string (correct)
dumps() is obsolete
Question 10
Which of the following Python objects is NOT correctly mapped to a JSON object?
dict → object
list → array
str → string
set → array
There are 10 questions to complete.