Module 8 Exercises

  1. Install pandas, numpy, or lxml using pip.

  2. Imagine that you have been tasked to create a module implementing some mathematical operations.

    • In order to keep the assignment simple, let’s practice by creating simple functions that add, subtract, multiply, and divide two integers.
    • Create a module called “new_math.py”
    • Create four functions in this module: add, subtract, multiply, and divide
    • Each function should take two arguments that are assumed to be positive integers (a, b).
    • Each function should return the sum, difference, product, or quotient, respectively, of the two integers.
    • Add docstrings to each function explaining what they do. In interactive mode, import your module and call help() to see the docstrings.
    • Now write tests for each function, first using assert statements inside the name equals main block.
    • next put your tests into their own functions named according to pytest’s pattern. Run pytest to check your code and tests. Make a failing test on purpose to ensure that your tests are working.
  3. Write tests for a program you have written using assert statements.

  4. Do some test-driven development with pytest: write a failing test, then code the solution.