""" Ex 3.7 from "A primer on... Write a function to evaluate a sum, and then a test function to test this function. """ #a) def sum_1k(M): s = 0 for k in range(1, M+1): s += 1 / k return s #b) def test_sum_1k(): M = 3 tol = 1e-15 #value for M = 3, calculated by hand: expected = 11 / 6 computed = sum_1k(M) assert abs(expected - computed) < tol test_sum_1k() """ Terminal> python sum_func.py (No output if the test passes) """