Create the mortgage calculator class
You started with a BasicCalculator
that performed basic arithmetic.
You then created a FinancialCalculator
which inherited from this BasicCalculator
. You extended this class by adding a method, monthly_interest()
, that calculates the monthly interest given the annual interest rate.
Now it's time to create the MortgageCalculator
class!
Diese Übung ist Teil des Kurses
Case Study: Building Software in Python
Anleitung zur Übung
- Instantiate the parent methods and attributes without invoking the parent by name.
- Initialize
self.loan_amount
using the appropriate parameter. - Use an inherited method to initialize
self.monthly_interest_rate
.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
class MortgageCalculator(FinancialCalculator):
def __init__(self, loan_amount, annual_interest_rate, years):
# Initialize the parent attributes and functions
____
# Initialize the loan_amount attribute
self.loan_amount = ____
# Initialize the monthly_interest_rate
self.monthly_interest_rate = self.____(annual_interest_rate)