第1关:按揭贷款——定义抽象类
def findPayment(loan, r, m):
# 请在下面编写代码
#-----------Begin----------
return loan*((r*(1+r)**m)/((1+r)**m-1))
#------------End-----------
# 请不要修改下面的代码
class Mortgage(object):
def __init__(self, loan, annRate, months):
# 请在下面编写代码
#-----------Begin----------
self.loan = loan
self.annRate = annRate
self.months = months
self.rate = self.annRate/12/100
self.paid = [0.0]
self.owed = [loan]
self.payment = findPayment(loan,self.rate,months)
#------------End-----------
# 请不要修改下面的代码
self.legend = None
def makePayment(self):
# 请在下面编写代码
#-----------