0
0
Pythonprogramming~20 mins

Why structured data formats are used in Python - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Structured Data Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why do we use structured data formats?

Which of the following is the main reason we use structured data formats like JSON or XML?

AThey slow down data processing to improve security.
BThey make data completely unreadable to humans.
CThey make data easy to read and write for both humans and machines.
DThey remove all data types and store everything as plain text.
Attempts:
2 left
💡 Hint

Think about how computers and people both need to understand data clearly.

Predict Output
intermediate
2:00remaining
Output of reading structured data

What will be the output of this Python code that reads a JSON string?

Python
import json
json_data = '{"name": "Alice", "age": 30}'
result = json.loads(json_data)
print(result['name'])
AAlice
B30
C{'name': 'Alice', 'age': 30}
Djson_data
Attempts:
2 left
💡 Hint

Look at what key is used to get the value from the dictionary.

Predict Output
advanced
2:00remaining
Parsing nested structured data

What is the output of this Python code that parses nested JSON data?

Python
import json
json_str = '{"person": {"name": "Bob", "contacts": {"email": "bob@example.com"}}}'
data = json.loads(json_str)
print(data['person']['contacts']['email'])
Abob@example.com
BBob
Ccontacts
DKeyError
Attempts:
2 left
💡 Hint

Follow the keys step by step to reach the email value.

🧠 Conceptual
advanced
2:00remaining
Benefits of structured data formats

Which of these is NOT a benefit of using structured data formats?

AThey allow easy data exchange between different systems.
BThey support automated data processing.
CThey help organize data in a predictable way.
DThey guarantee data is always encrypted.
Attempts:
2 left
💡 Hint

Think about what structured data formats do and what they do not do.

Predict Output
expert
2:00remaining
Handling invalid structured data

What error will this Python code raise when trying to parse invalid JSON?

Python
import json
invalid_json = '{"name": "Eve", "age": 25,'
json.loads(invalid_json)
ANo error, outputs a dictionary
Bjson.decoder.JSONDecodeError
CTypeError
DKeyError
Attempts:
2 left
💡 Hint

Look at the JSON string carefully for syntax mistakes.