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 | |
|---|---|---|
| 1int(row[2]) | ARemoves extra spaces from both ends of the text and capitalises each word | |
| 2name.strip().title() | BThe brackets are missing, so the method is not called and the text is never changed. It should be name.upper(). | |
| 3Transform every record in a stream by converting its price field from text to a float | Ctotal = price * qty | |
| 4Add a derived field to each record by calculating a new value from existing fields | D[float(r[1]) for r in rows] | |
| 5price = row[2] total = price * 2 | EConverts a text field from a CSV line into a whole number so it can be used in calculations | |
| 6name.upper | Frow[2] is still a string from the CSV file, so it must be converted with int() or float() first. Otherwise the multiplication repeats the text instead of calculating a number. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
map — map() applies a function to every record in a stream and gives back changed records, such as converting a type, trimming and changing the case of text, or computing a derived field.prices = list(map(float, raw_prices))ages = list(map(int, ages_text))names = list(map(lambda s: s.strip(), raw))gross = list(map(lambda p: p * 1.1, nums))shout = list(map(str.upper, houses))