Quiz — Lecture 11

Section A from memory, one line each. Section B shows your reasoning - marks are for method, not final answers. Answers are discussed in class; the exit ticket goes on a card.

Section A

A1. After b = a, what does b.append(x) do to a?

A2. What is the idiom for a full list copy?

A3. sort() vs sorted(): what is the difference?

A4. What does a[len(a):] evaluate to?

Section B

B1. grid = [[0]3]2: what goes wrong writing grid[0][0]=1, and what is the fix?

B2. Rotate [1,2,3,4,5] left by 2 using slices; give the result.

Exit ticket

Answer one of these on your card in 60 seconds (choose any one):

  1. What is the difference between a = b and a = b[:] for lists?
  1. Give the slice for the last three items and for every second item.
  1. Why did the roster corrupt in cs-044?

Homework