How do we know if software works?
Software testing is the act of checking whether software satisfies expectations.
def square(n): return n*n
How do we know if this code works?
assert
false
assert(1==1) # Confirms that 1 is 1 assert(1==2) # Raises AssertionError
def square(n): return n*n assert(square(0) == 0) assert(square(1) == 1) assert(square(2) == 4) assert(square(25) == 625)