Skip to content

Commit

Permalink
Python Future Date code snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
CoreyMSchafer committed Jan 18, 2018
1 parent 206aec5 commit 1514054
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Python-Future-Date/credit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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)
13 changes: 13 additions & 0 deletions Python-Future-Date/subs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import datetime
import math

goal_subs = 150000
current_subs = 85000
subs_to_go = goal_subs - current_subs

avg_subs_day = 200
days_to_go = math.ceil(subs_to_go / avg_subs_day)

today = datetime.date.today()

print(today + datetime.timedelta(days=days_to_go))
15 changes: 15 additions & 0 deletions Python-Future-Date/weight.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import datetime

current_weight = 220
goal_weight = 180
avg_lbs_week = 2

start_date = datetime.date.today()
end_date = start_date

while current_weight > goal_weight:
end_date += datetime.timedelta(days=7)
current_weight -= avg_lbs_week

print(end_date)
print(f'Reached goal in {(end_date - start_date).days // 7} weeks')

0 comments on commit 1514054

Please sign in to comment.