Lesson 11 · Review
Gotcha gauntlet
Six traps that catch experienced developers in their first month of Python. Predict each answer before you click.
Quiz: What does this print?
a = [1, 2] b = [1, 2] print(a == b, a is b)
Quiz: What does this print?
a = [1, 2] b = a b.append(3) print(a)
Quiz: What does this print?
for i in range(3):
pass
print(i)Quiz: What does this print?
funcs = [lambda: i for i in range(3)] print([f() for f in funcs])
Quiz: What happens?
s = "hello" s[0] = "H"
Quiz: What does this print?
print(-7 // 2, int(-7 / 2))
Where next?
- Read the official tutorial at docs.python.org/3/tutorial. It's short and written for programmers.
- Do the Exercism Python track for more small, idiomatic exercises.
- Read Fluent Python (Ramalho) once the basics feel natural.
- Rebuild something you've already made, such as a CLI tool with
argparseor an API with FastAPI.