Up to now, you've checked your own code the same way most beginners do: run it, look at the output, decide if it looks right. That works fine for a five-line function. It falls apart fast once a program grows — you can't re-eyeball every function every time you change something, and "looks right" isn't a reliable check anyway (it's easy to glance past a wrong answer that merely looks plausible).
A test is code that checks other code, automatically, by comparing an actual result to an expected one — and tells you clearly, in words, when they don't match, instead of you having to notice a wrong number buried in a wall of output.
# instead of this:
print(add(2, 3)) # you read "5" and decide for yourself if that's right
# you write this:
assert add(2, 3) == 5 # Python itself checks it, and raises an error if it's wrong
assert is a Python keyword that does exactly this: if the condition after it is True, nothing happens. If it's False, Python raises an AssertionError immediately. That's the fundamental building block every testing tool — including the one you'll use in this section — is built on top of.
The real payoff of tests isn't catching bugs the first time you write a function — it's catching regressions: bugs you accidentally introduce later, while changing something else entirely. Without tests, you'd have to remember to manually re-check every function that might be affected, every time you change anything. With tests, you just re-run them — in a second, they tell you exactly what broke.
Every problem so far has asked you to implement a function, and graded you by running hidden tests against it. This section flips that: you'll be given a function's specification (and sometimes its implementation), and your job is to write the tests — the same skill a real engineer uses constantly, whether or not someone else already wrote the code being tested.