Concept
assert states something that must be true at that point in the code, and stops with an AssertionError if it is not. In tests it is how you check a result; in production code it documents assumptions.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show Assertions doing its job.
def median(values):
s = sorted(values)
mid = len(s) // 2
return s[mid] if len(s) % 2 else (s[mid - 1] + s[mid]) / 2
assert median([3, 1, 2]) == 2
assert median([4, 1, 3, 2]) == 2.5
assert median([7]) == 7Using assert to validate user input or guard production code. Python skips every assert when run with -O, so the check silently disappears. Raise a real exception instead.
Your roadmap puts these before Assertions, unless you already know them.
Once a session shows you understand Assertions, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.
Topics that build on Assertions.