"""function_example_3.py See function_example_2. This adds doctests. Things to try : $ python function_example_3.py ********************************************************************** File "function_example_3.py", line 17, in __main__.triple Failed example: triple(10) # oops - this test will fail. (Quick quiz: why?) Expected: 30.0 Got: 30 ********************************************************************** 1 items had failures: 1 of 2 in __main__.triple ***Test Failed*** 1 failures. Read about doctests at https://docs.python.org/3/library/doctest.html i.e. google "python doctest" . There are other testing approaches, as you can find by googling "python testing". Jim Mahoney | cs.bennington.college | September 2020 | MIT License """ def triple(x): """ Return three times x. >>> triple(3) # a "doctest" ; gives and example and a test 9 >>> triple(10) # oops - this test will fail. (Quick quiz: why?) 30.0 """ y = 3 * x return y def main(): """ Ask for a number, triple it, print the result. """ value = eval(input("Type a number: ")) answer = triple(value) print(f"Three times {value} is {answer}.") # This is "boilerplate" code that you should put at the # bottom of any file (i.e. "module") that uses doctests . # (And has a main() function to run the top-level of the program.) if __name__ == '__main__': import doctest # load the doctest library doctest.testmod() # test module, i.e. try all > > > lines. main()