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 | |
|---|---|---|
| 1people = [{'name':'Ali'}] print(people['name']) | AError: people is a list, use [0] | |
| 2d = {'tags': ['a','b']} print(d['tags']['a']) | BOk: Append to list inside dict | |
| 3people = [{'name':'Ali'},{'name':'Bo'}] people[0]['name'] | CError: Use integer index for list | |
| 4d = {'nums': [1,2,3]} d['nums'].append(4) | DOutput: Ali Bo | |
| 5p = [{'n':'Ali'},{'n':'Bo'}] for x in p: print(x['n']) | EValid: Returns 'Ali' | |
| 6d = {'c':['r','g']} print(d['c'][1]) | FOutput: g |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
List of dicts — A list where each element is a dictionary like records.~~list[i]['key']people = [{'name': 'Alice'}]
print(people[0]['name'])d = {'items': [1, 2, 3]}
print(d['items'][0])people = []
people.append( {'name': 'Bob'} )for person in people:
print(person['name'])student = {'scores': [90, 85]}
student['scores'].append(95)