-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPage-To-Read-Before-Exam.py
81 lines (66 loc) · 2.23 KB
/
Page-To-Read-Before-Exam.py
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
#import calendar
#x=int(input("Number of Pages:"))
#y=int(input("Input the date:"))
#print(calendar.month(x,y))
#now = datetime.datetime.now()
#print(now)
#d0 = datetime.datetime.now()
#a= datetime.datetime.now().date
#print x,y
#-------------------------Libraries-------------------------
import datetime
import calendar
#-------------------------Define Var. For Current Month and Year-------------------------
x = datetime.datetime.now().year
y = datetime.datetime.now().month
#-------------------------Define Var. For Current Date and Target Date-------------------------
d0 = datetime.datetime.today() #Today's Date
def GetDatefunc():
while True:
try:
UserIn = input("Start Date (DD/MM/YYYY):")
ds = datetime.datetime.strptime(UserIn, "%d/%m/%Y")
except Exception as e:
print ("ops watch the format!")
else:
return ds
def GetDatefunc2():
while True:
try:
UserIn2 = input("End Date (DD/MM/YYYY):")
df = datetime.datetime.strptime(UserIn2, "%d/%m/%Y")
except Exception as e:
print ("ops watch the format!")
else:
return df
ds = GetDatefunc()
df = GetDatefunc2()
#ds = datetime.date(2017,12,13)
#df = datetime.date(2017,12,27)
#tmr = datetime.date.today() + datetime.timedelta(days=1)
#-------------------------Calculate Differences-------------------------
dealta = df - d0
dealtac = df - ds
dealc = d0 - ds
#-------------------------Define Page Number and Calculate Average Page per Day-------------------------
def GetPagefunc():
while True:
try:
Page = int(input("Enter the Amount of Page:"))
except Exception as e:
print ("ops make sure it's a number")
else:
return Page
Page = GetPagefunc()
PageLeftc = Page / dealtac.days
PageLeft = Page - dealc.days * PageLeftc
#Page = 300.0
#PageLeft = Page - dealta.days * PageLeftc
#PageLeft = Page - dealta.days * int(PageLeftc)
#round (Page / dealta.days, 2)
#-------------------------Print Outputs-------------------------
print(calendar.month(x,y))
print ("Time till Exam:", dealta.days)
print ("Page Per Day:", round(PageLeftc,2))
print ("Page Left:", round(PageLeft,2))
#print ("Page Left:", PageLeft)