-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdayknower.py
More file actions
118 lines (98 loc) · 2.54 KB
/
dayknower.py
File metadata and controls
118 lines (98 loc) · 2.54 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#hello do i get the change
class checktheday:
def __init__(self):
pass
def date(self):
date = int(input("enter the date"))
if 0 > date or date > 31:
print("enter a valid date")
return date%7
def checkleap(self,k):
return (k % 4 == 0 and (k % 100 != 0 or k % 400 == 0))
def month(self):
mont = int(input("enter month number"))
if mont < 0 or 12 < mont:
return "enter a valid month"
l = str(mont)
nonleap = {
"1": 1,
"2":4,
"3":4,
"4":0,
"5":2,
"6": 5,
"7":0,
"8":3,
"9":6,
"10":1,
"11": 4,
"12":6,
}
leap = {
"1": 0,
"2":3,
"3":4,
"4":0,
"5":2,
"6": 5,
"7":0,
"8":3,
"9":6,
"10":1,
"11": 4,
"12":6,
}
if self.checkleap(self.y) == True:
return leap[l]
return leap[l]
def year(self):
self.y = int(input("enter the year"))
if self.y <= 1200 or self.y >= 2800:
return("enter a valid year in between 18s to 20s")
k = str(self.y)
j = (k[:2])
(last) = k[2:]
(last_digit) = int(last)
rem = (last_digit%7)
qutiont = (last_digit//4)
d = {
"12" :-1,
"13" : 4,
"14" : +2,
"15" :0,
"16":-1,
"17": 4,
"18" : +2,
"19" : 0,
"20" : -1,
"21" : +4,
"22" : +2,
"23" : 0,
"24" :-1,
"25" : +4,
"26" : +2,
"27" : 0,
"28" :1,
}
final = ((d[j]+rem+qutiont) + self.month() +self.date())%7
try :
if final == 1:
return "sunday"
elif final == 2:
return "monday"
elif final == 3:
return "tuesday"
elif final == 4:
return "wednesday"
elif final == 5:
return "Thrusday"
elif final == 6:
return "friday"
elif final == 7:
return "saturday"
else:
return "you have entered someting wrong"
except :
print("you enterd soemthing wrong")
s = checktheday()
print(s.year())