Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- months = {"1":11, "2":12, "3":1, "4":2, "5":3, "6":4,
- "7":5, "8":6, "9":7, "10":8, "11":9, "12":10}
- days = {"1":"Monday", "2":"Tuesday","3":"Wednesday","4":"Thursday","5":"Friday","6":"Saturday","0":"Sunday"}
- bMonth = "0"
- bDay = "0"
- bYear = "0"
- bCent = "0"
- today = datetime.now()
- born = "You were born on a "
- validInput = False
- while (validInput == False):
- while(len(bYear)!=2):
- bYear = input("Want to know the day of the week you were born?\n Enter the two digit year: \n(e.g. if you were born in 1980 enter 80) YY ")
- try:
- bYear = int(bYear)
- if bYear >= 0 and bYear <= 99:
- validInput = True
- else:
- bYear= input("Want to know the day of the week you were born?\n Enter the two digit year: \n(e.g. if you were born in 1980 enter 80) YY ")
- except ValueError:
- bYear = input("You made an invalid entry. \nEnter the two digit year: \n(e.g. if you were born in 1980 enter 80) YY ")
- validInput = False
- while (validInput == False):
- while(len(bCent)!=2):
- bCent = input("Enter the two digit century: \n(e.g. if you were born in 1980 enter 19) CC ")
- try:
- bCent = int(bCent)
- if bCent >= 0 and bCent <= 99:
- validInput = True
- else:
- bCent= input("Enter the two digit century: \n(e.g. if you were born in 1980 enter 19) CC ")
- except ValueError:
- bCent = input("You made an invalid entry. \nEnter the two digit century: \n(e.g. if you were born in 1980 enter 19) CC ")
- validInput = False
- while (validInput == False):
- while(len(bMonth)!=2):
- bMonth = input("Enter a number for the month: MM ")
- try:
- bMonth = int(bMonth)
- if bMonth >= 1 and bMonth <= 12:
- validInput = True
- else:
- bMonth = input("Enter a number for the month: MM ")
- except ValueError:
- bMonth = input("You made an invalid entry. \nEnter a number for the month: MM ")
- validInput = False
- while (validInput == False):
- while(len(bDay)!=2):
- bDay = input("Enter a number for the day: DD ")
- try:
- bDay = int(bDay)
- if bMonth == 2:
- if bYear%4 == 0:
- if bDay >=1 or bDay <= 29:
- validInput = True
- else:
- if bDay >=1 or bDay <= 28:
- validInput = True
- elif bMonth == 9:
- if bDay >= 1 or bDay <=30:
- validInput = True
- elif bMonth == 4:
- if bDay >= 1 or bDay <=30:
- validInput = True
- elif bMonth == 6:
- if bDay >= 1 or bDay <=30:
- validInput = True
- elif bMonth == 11:
- if bDay >= 1 or bDay <=30:
- validInput = True
- elif bMonth == 1:
- if bDay >= 1 or bDay <=31:
- validInput = True
- elif bMonth == 3:
- if bDay >= 1 or bDay <=31:
- validInput = True
- elif bMonth == 5:
- if bDay >= 1 or bDay <=31:
- validInput = True
- elif bMonth == 7:
- if bDay >= 1 or bDay <=31:
- validInput = True
- elif bMonth == 8:
- if bDay >= 1 or bDay <=31:
- validInput = True
- elif bMonth == 10:
- if bDay >= 1 or bDay <=31:
- validInput = True
- else:
- bDay= input("Enter a number for the day: DD ")
- except ValueError:
- bDay = input("You made an invalid entry. \nEnter a number for the day: DD ")
- if today.year < int(str(bCent)+str(bYear)):
- born = "You will born on a "
- A = int(months[str(bMonth)])
- B = int(bDay)
- if A == 11 or A == 12:
- if bYear == 00:
- bYear = 99
- bCent = bCent - 1
- else:
- bYear = bYear - 1
- C = bYear
- D = bCent
- W = int((13*A - 1) / 5)
- X = int(C / 4)
- Y = int(D / 4)
- Z = int(W + X + Y + B + C - 2*D)
- R = int((Z%7))
- if (R < 0):
- R = (R+7)%6
- print (born + days[str(R)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement