-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhomework5.py
More file actions
27 lines (22 loc) · 786 Bytes
/
homework5.py
File metadata and controls
27 lines (22 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
balance = 999999
annualInterestRate = 0.18
def remaining_balance(balance, ann, pay, n=12):
if n == 0:
return round(balance, 2)
else:
rbalance = (remaining_balance(balance, ann, pay, n-1) - pay) * (1+(ann/12))
return round(rbalance, 2)
def find_payment(balance, ann):
lpay = round(balance/12, 2)
upay = round(balance*((1+(ann/12))**12), 2)
payment = round((lpay+upay)/2, 2)
while abs(remaining_balance(balance, ann, payment)) >= 1:
test = remaining_balance(balance, ann, payment)
if remaining_balance(balance, ann, payment) > 0:
lpay = payment
else:
upay = payment
payment = round((lpay+upay)/2, 2)
print(payment)
return payment
find_payment(balance, annualInterestRate)