-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab15b.py
69 lines (64 loc) · 3.11 KB
/
lab15b.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
import calendar
def birthmonth():
# Takes user input for birth date information and prints the calendar of that month
birthYear = raw_input("Enter the year of your birth: ")
birthMonth = raw_input("Enter the month of your birth as an integer: ")
try:
calendar.prmonth(int(birthYear),int(birthMonth))
except ValueError:
showInformation("Enter appropriate integers only. Try again")
birthmonth()
def daysTilBirthday():
# Calculates and output the number of days until the user's next birthday
currentDay = raw_input ("Enter the current day as an integer: ")
currentMonth = raw_input("Enter the current month as an integer: ")
currentYear = raw_input("Enter the current year as an integer: ")
birthDay = raw_input("Enter the day of your birth as an integer: ")
birthMonth = raw_input("Enter the month of your birth as an integer: ")
try:
currentDay = int(currentDay)
currentMonth = int(currentMonth)
currentYear = int(currentYear)
birthDay = int(birthDay)
birthMonth = int(birthMonth)
except ValueError:
showInformation("Enter appropriate integers only. Try again")
daysTilBirthday = 0
if currentMonth == birthMonth:
daysTilBirthday = int(birthDay) - int(currentDay)
elif currentMonth < birthMonth:
for days in range (currentDay, calendar.monthrange(currentYear,currentMonth)[1]): # add the days left in this month
daysTilBirthday += 1
for month in range (currentMonth + 1, birthMonth): # add the days until birthMonth
daysTilBirthday += calendar.monthrange(currentYear,month)[1]
for days in range (1,birthDay): #add the days in the birthMonth before birthDay
daysTilBirthday += 1
else:
for days in range (currentDay, calendar.monthrange(currentYear,currentMonth)[1] + 1): # add the days left in this month
daysTilBirthday += 1
for month in range (currentMonth + 1, birthMonth): # add the days until birthMonth
daysTilBirthday += calendar.monthrange(currentYear,month)[1]
for days in range (1,birthDay): #add the days in the birthMonth
daysTilBirthday += 1
for month in range (1,birthMonth): #add the days in the next year until birthMonth
daysTilBirthday += calendar.monthrange(currentYear + 1,month)[1]
for days in range (1,birthDay):
daysTilBirthday += 1
showInformation ("There are " + str(daysTilBirthday) + " until your birthday.")
def weekdayOfDec():
decDay = calendar.weekday(1776,7,4)
if decDay == 0:
showInformation ("The Declaration of Independence was signed on a Monday")
elif decDay == 1:
showInformation ("The Declaration of Independence was signed on a Tuesday")
elif decDay == 2:
showInformation ("The Declaration of Independence was signed on a Wednesday")
elif decDay == 3:
showInformation ("The Declaration of Independence was signed on a Thursday")
elif decDay == 4:
showInformation ("The Declaration of Independence was signed on a Friday")
elif decDay == 5:
showInformation ("The Declaration of Independence was signed on a Saturday")
elif decDay == 6:
showInformation ("The Declaration of Independence was signed on a Sunday")
print decDay