forked from CoreyMSchafer/code_snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcredit.py
More file actions
27 lines (20 loc) · 743 Bytes
/
credit.py
File metadata and controls
27 lines (20 loc) · 743 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
import datetime
import calendar
balance = 10000
interest_rate = 13 * .01
monthly_payment = 1000
today = datetime.date.today()
days_in_current_month = calendar.monthrange(today.year, today.month)[1]
days_till_end_month = days_in_current_month - today.day
start_date = today + datetime.timedelta(days=days_till_end_month + 1)
end_date = start_date
while balance > 0:
interest_charge = (interest_rate / 12) * balance
balance += interest_charge
balance -= monthly_payment
balance = round(balance, 2)
if balance < 0:
balance = 0
print(end_date, balance)
days_in_current_month = calendar.monthrange(end_date.year, end_date.month)[1]
end_date = end_date + datetime.timedelta(days=days_in_current_month)