ComeçarComece de graça

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!

Este exercício faz parte do curso

Case Study: Building Software in Python

Ver curso

Instruções do exercício

  • 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.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

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)
Editar e executar o código