Module 8 Exercises
Install pandas, numpy, or lxml using pip.
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.
Write tests for a program you have written using assert statements.
Do some test-driven development with pytest: write a failing test, then code the solution.