Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1json.dumps({"name": "Ava"}) | A{"city": "Brisbane", "temp": 28} | |
| 2json.loads('{"score": 90}') | BTurns JSON text back into a Python dictionary | |
| 3json.dumps() turns a list into JSON text with square brackets | Cjson.dumps() was used to turn JSON text back into Python data. It should be json.loads(data), because dumps() only creates JSON text. | |
| 4JSON key-value pairs sit inside braces and the keys use double quotes | DThe keys and strings use single quotes. Valid JSON text needs double quotes: {"name": "Ava", "age": 17}. | |
| 5data = json.dumps(text) person = json.dumps(data) | ETurns a Python dictionary into JSON text that can be sent | |
| 6{'name': 'Ava', 'age': 17} | Fjson.dumps([1, 2, 3]) |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
json.dumps() — Turns a Python dictionary or list into JSON text (double-quoted keys, braces, square brackets) ready to send. json.loads() does the reverse and turns JSON text back into Python data.import json
user = {"name": "Mia", "year": 12}
text = json.dumps(user)user = {"name": "Mia", "year": 12}
text = json.dumps(user)
print(text)text = '{"name": "Mia", "year": 12}'
data = json.loads(text)
print(data)scores = [88, 74, 91]
text = json.dumps(scores)
print(text)user = {"name": "Mia", "year": 12}
payload = json.dumps(user)
print(type(payload))