Case Study: Building Software in Python
Build a mortgage calculator in Python and practice modular design, inheritance, docstrings, Pylint checks and pytest tests along the way.
You build a mortgage calculator in Python that works out monthly payments based on the loan amount, interest rate and loan term. The project begins with simple calculator classes and grows through inheritance into a financial calculator and a mortgage calculator. Documentation, automated tests and code review keep the code modular and easy to maintain as it expands, so the engineering habits are practiced on code that keeps changing.
What You Will Achieve
- Split a Python project into modules and connect them with relative or absolute imports
- Extend existing classes through multilevel inheritance to add calculator features without repeating code
- Write docstrings for your classes and check their behavior with doctest
- Review and refactor code with Pylint, then verify it with a pytest unit test suite
Program Overview
Case Study Brief and Calculator Classes
Sets out the mortgage calculator brief and builds the first calculator classes while recapping object-oriented and software engineering principles.
- BasicCalculator and FinancialCalculator classes
- The DRY principle and other engineering principles
- Relative and absolute imports
- Inheritance, multilevel inheritance and the mortgage calculator class
Documenting and Testing a Python Module
Adds documentation and first automated tests to the calculator code and extends what the inherited classes can do.
- Docstrings and the dir() function
- Automated testing with doctest
- Inspecting a custom class with dir()
- Adding a method to an inherited class
Code Review, Refactoring and Unit Testing
Checks that the finished calculators work as intended and follow best practices through review, refactoring and fuller tests.
- Maintainability and good variable names
- Code quality checks with Pylint
- Code review and refactoring
- Benefits of unit testing and tests with pytest
Certificate Awarded (Paid)
Job Outlook
These skills apply wherever Python applications are built and maintained by teams, where code is split into modules, documented, reviewed, refactored and covered by automated tests before it changes hands.
Good for: Python programmers comfortable with classes who want to apply structure, documentation and testing habits to one small application they build step by step.
Keep in mind: Despite its advanced label, it is a guided case study on one mortgage calculator that recaps engineering habits; testing starts with doctest, and pytest appears only in the closing chapter.
Bottom line: A single running project ties imports, inheritance, docstrings, Pylint and pytest together, so each practice is seen applied to the same growing code.
Frequently Asked Questions
What does the mortgage calculator compute?
It works out monthly payments from three inputs: the loan amount, the interest rate and the loan term. Later lessons add a financial calculator and a mortgage calculator class that build on the basic one through inheritance.
How are the calculator files linked together?
The first chapter compares relative and absolute imports for connecting the calculator modules, then uses inheritance and multilevel inheritance so the advanced calculators reuse code from the basic one instead of repeating it.
Which testing tools does the case study use?
Two of them. The second chapter introduces automated testing with doctest alongside the docstrings that document the new class. The final chapter looks at why unit testing helps and has you test the calculator code with pytest.


There are no reviews yet.