Quiz — Lecture 15

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. When is a mutable default argument created?

A2. What is the standard fix?

A3. Reassigning a parameter vs mutating it: which does the caller see?

A4. is vs ==: what does each test?

Section B

B1. Fix def add_tag(tag, tags=[]) and explain in one sentence.

B2. Predict the output: def f(x, acc=[]): acc.append(x); return acc - called f(1), f(2).

Exit ticket

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

  1. When is the complement trick the right tool?
  1. Permutations vs combinations in one phrase each.
  1. How does simulation back up counting?

Homework