Dear all,
In the mortgage.py code as stated below, please can someone explain why we have (1+rate/12)
I am not able to wrap my head around why we need to add 1 to that line
principal = 500000.0
rate = 0.05
payment = 2684.11
total_paid = 0.0
while principal > 0:
principal = principal * (1+rate/12) - payment
total_paid = total_paid + payment
print('Total paid', total_paid)
def getitem(self, index):
return self._holdings[index]
import report
portfolio = report.read_portfolio('Data/portfolio.csv')
Hello. For the sake of clarity: in the following example, here: https://github.com/dabeaz-course/practical-python/blob/master/Notes/03_Program_organization/05_Main_module.md#script-template, instead of:
# Main function
def main(argv):
# Parse command line args, environment, etc.
...
shouldn't it have been def main(args)
, just like in the solution? I'm asking, because argv
is very confusing in this context, given that you think automatically about sys.argv
, which isn't supposed to appear in the definition. Or is that intentional so that the students can figure it out for themselves?
@dabeaz: Hello. I think there's a mistake here:
https://github.com/dabeaz-course/practical-python/blob/master/Notes/04_Classes_objects/01_Class.md
In the code in exercise 4.3, there's no attribute "cost":
sum([s.cost() for s in portfolio])
principal = 500000.0
rate = 0.05
payment = 2684.11
total_paid = 0.0
month = 0
extra_payment_start_month = 61
extra_payment_end_month = 108
extra_payment = 1000
while principal > 0:
if extra_payment_end_month >= month >= extra_payment_start_month:
payment = 2684.11 + extra_payment
principal = principal * (1+rate/12) - (payment)
else:
payment = 2684.11
principal = principal * (1+rate/12) - (payment)
if payment >= principal:
payment = principal
month = month + 1
total_paid = total_paid + payment
print("%d %.2f %.2f" % (month, total_paid, principal))
print('Total paid %.2f , months: %d' % (total_paid, month))