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 | |
|---|---|---|
| 1frozenset({1,2}).add(3) | AOk: Create an immutable frozenset | |
| 2[x for x in range(5)] | BValid: Set comprehension | |
| 3{x**2 for x in range(5)} | COutput: 3 | |
| 4frozenset({1, 2, 3}) | DOutput: {0, 2, 4} | |
| 5len({1, 2, 2, 3}) | EError: frozenset is immutable — no add method | |
| 6{x for x in range(6) if x%2==0} | FError: This is a list, not a set comprehension |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Set comprehension — {expression for item in iterable} builds a set concisely.~~frozensetsquares = {x**2 for x in range(5)}evens = {x for x in range(10) if x % 2 == 0}fs = frozenset( {1, 2, 3} )unique = set(['a', 'b', 'a'])d = {frozenset({1, 2}): 'pair'}