Introduction
Preconditions help you check if things are right before your program continues. They stop the program early if something is wrong.
When you want to make sure a function gets a valid input.
When you want to stop the program if a condition is not met.
When you want to give a clear message about what went wrong.
When you want to avoid bugs by catching errors early.
When you want to check assumptions in your code.