-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathEX5.30.py
69 lines (65 loc) · 2.24 KB
/
EX5.30.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
# 5.30 (Display the first days of each month) Write a program that prompts the user
# to enter the year and first day of the year, and displays the first day of each month
# in the year on the console. For example, if the user entered year 2013, and 2 for
# Tuesday, January 1, 2013, your program should display the following output:
# January 1, 2013 is Tuesday
# ...
# December 1, 2013 is Sunday
year = eval(input("Enter a year: "))
firstDay = eval(input("Enter the first day of the year: "))
numberOfDaysInMonth = 0
for month in range(1, 13):
if month == 1:
print("January 1,", year, "is ", end="")
numberOfDaysInMonth = 31
elif month == 2:
print("February 1,", year, "is ", end="")
if (year % 400 == 0 or (year % 4 == 0 and year % 100 != 0)):
numberOfDaysInMonth = 29
else:
numberOfDaysInMonth = 28
elif month == 3:
print("March 1,", year, "is ", end="")
numberOfDaysInMonth = 31
elif month == 4:
print("April 1,", year, "is ", end="")
numberOfDaysInMonth = 30
elif month == 5:
print("May 1,", year, "is ", end="")
numberOfDaysInMonth = 31
elif month == 6:
print("June 1,", year, "is ", end="")
numberOfDaysInMonth = 30
elif month == 7:
print("July 1,", year, "is ", end="")
numberOfDaysInMonth = 31
elif month == 8:
print("August 1,", year, "is ", end="")
numberOfDaysInMonth = 31
elif month == 9:
print("September 1,", year, "is ", end="")
numberOfDaysInMonth = 30
elif month == 10:
print("October 1,", year, "is ", end="")
numberOfDaysInMonth = 31
elif month == 11:
print("November 1,", year, "is ", end="")
numberOfDaysInMonth = 30
elif (month == 12):
print("December 1,", year, "is ", end="")
numberOfDaysInMonth = 31
if firstDay == 0:
print("Sunday")
elif firstDay == 1:
print("Monday")
elif firstDay == 2:
print("Tuesday")
elif firstDay == 3:
print("Wednesday")
elif firstDay == 4:
print("Thursday")
elif firstDay == 5:
print("Friday")
elif firstDay == 6:
print("Saturday")
firstDay = (firstDay + numberOfDaysInMonth) % 7