forked from aiti-ghana-2012/Lab_Python_01
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzellers.py
More file actions
62 lines (41 loc) · 1.63 KB
/
Copy pathzellers.py
File metadata and controls
62 lines (41 loc) · 1.63 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
"""
Zeller’s algorithm computes the day of the week on which a given date will fall (or fell). In
this exercise, you will write a program to run Zeller’s algorithm on a specific date. You
will need to create a new file for this program, zellers.py. The program should use the
algorithm outlined below to compute the day of the week on which the user’s birthday fell
in the year you were born and print the result to the screen.
Let A, B, C, D denote integer variables that have the following values:
A = the month of the year, with March having the value 1, April the value 2, ... December
the value 10, and January and February being counted as months 11 and 12 of the
preceding year (in which case, subtract 1 from C)
B = the day of the month (1, 2, 3, ... , 30, 31)
C = the year of the century (e.g. C = 89 for the year 1989)
D = the century (e.g. D = 19 for the year 1989)
Note: if the month is January or February, then the preceding year is used for
computation. This is because there was a period in history when March 1st, not January
1st, was the beginning of the year.
"""
A=raw_input('Enter month as a number between 1 and 12: ')
B=raw_input('Enter the day of the month as numbers between 1 and 31: ')
year=raw_input('Enter year (eg. 1999): ')
A=int(A)
A=A-2
if A<0:
A=A+12
B=int(B)
C=int(year)%100
D=int(year)/100
if A==11:
print '11th month'
C=C-1
if A==12:
print '12th month'
C=C-1
# print A,' ',B,' ',C,' ',D
W = (13*A - 1) / 5
X=C/4
Y=D/4
Z = W + X + Y + B + C - 2*D
R=Z % 7
months=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
print A+2,'/',B,'/',year,' falls on ' + months[R]