-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatetime_Use_Problems.py
More file actions
executable file
·89 lines (56 loc) · 2.69 KB
/
datetime_Use_Problems.py
File metadata and controls
executable file
·89 lines (56 loc) · 2.69 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#----------------------------------------------------------------------------------------------#
# Calculate Number of Days , Weeks or Months to Reach Specific goals
# Using the Datetime Modules
#----------------------------------------------------------------------------------------------#
import datetime
import calendar
#----------------------------------------------------------------------------------------------#
# Making the pay off the credit card bill
#----------------------------------------------------------------------------------------------#
balance = 6000
interset_rate =13 *.01
monthly_payment = 623
today = datetime.date.today()
days_in_current_month = calendar.monthrange(today.year,today.month)[1] #year , month
print(days_in_current_month)
days_till_end_month= days_in_current_month-today.day
print(days_till_end_month)
start_date = today + datetime.timedelta(days=days_till_end_month+1) #staring on the month of the first adding the 1
end_date = start_date #for new month date
while balance > 0:
interset_charge = (interset_rate/12)*balance
balance+= interset_charge
balance-= monthly_payment
balance = round(balance,2)
if balance < 0 : #setting the balance to equal to 0
balance = 0
#balance = 0 if balance<0 else round(balance,2)
print(end_date, balance)
days_in_current_month = calendar.monthrange(end_date.year, end_date.month)[1] #get the days in the month
end_date = end_date + datetime.timedelta(days= days_till_end_month) #then the next month increment
#------------------------------------------------------------------
# Finding the Number of week days to loose the certain weight and goal date
#------------------------------------------------------------------------
import datetime
current_weight = 220
goal_weight = 180
avg_kg_week = 1.5
start_date1 = datetime.date.today()
end_date1 = start_date1
while current_weight > goal_weight:
end_date1 += datetime.timedelta(days=7)
current_weight -= avg_kg_week
print(f' You can reach to your goal in {(end_date1 - start_date1).days//7} weeks') #time delta has .days for end and start date
print(end_date1)
#-----------------------------------------------------
# finding the days to hit number of subscriber on channel
#--------------------------------------
import datetime
import math
goal_subscription = 1000000
current_subs = 100000
required_subs = goal_subscription -current_subs
avg_subs_day = 600
days_for_subs = math.ceil(required_subs/avg_subs_day) # round up the value and Return the ceiling of x as an Integral.This is the smallest integer >= x.
today = datetime.date.today()
print(today + datetime.timedelta(days=days_for_subs))