Using good variable names
Proper variable naming conventions improve readability, enhance maintainability, and reduce errors. Use proper naming conventions to name a class and a function.
Este ejercicio forma parte del curso
Case Study: Building Software in Python
Instrucciones del ejercicio
- Use the proper variable name for the class. Choose from
mortgage_calculatororMortgageCalculator? - Use the proper variable name for the function. Choose from
calculate_monthly_paymentorCalculateMonthlyPayment?
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# Use proper naming conventions for a class name
class ____(FinancialCalculator):
def __init__(self, loan_amount, annual_interest_rate, years):
super().__init__()
self.loan_amount = loan_amount
self.monthly_interest_rate = self.monthly_interest(annual_interest_rate)
self.months = self.multiply(years, 12)
# Use proper naming conventions for a function name
def ____(self):
numerator = self.monthly_interest_rate * (1 + self.monthly_interest_rate) ** self.months
denominator = (1 + self.monthly_interest_rate) ** self.months - 1
multiplier = self.divide(numerator, denominator)
monthly_payment = round(self.multiply(self.loan_amount, multiplier), 2)
return monthly_payment