Skip to content

Commit 0a9a40f

Browse files
committed
ex 1.8 version of morgage
1 parent 04ed212 commit 0a9a40f

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

‎Work/mortgage.py‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
# mortgage.py
22
#
3-
# Exercise 1.7
3+
# Exercise 1.8
44

55
principal = 500_000.0
66
rate = 0.05
7-
payment = 2684.11
7+
regular_payment = 2684.11
8+
extra = 1000
89
total_paid = 0.0
910

11+
months = 0
12+
1013
while principal > 0:
14+
if months < 12:
15+
payment = regular_payment + extra
16+
else:
17+
payment = regular_payment
18+
1119
principal = principal * (1+rate/12) - payment
1220
total_paid = total_paid + payment
21+
months = months + 1
1322

1423
print('Total paid', total_paid)
24+
print('Months', months)

0 commit comments

Comments
 (0)