# Author: James Tam # Version: July 3, 2014 # Employed named constants for the months instead of unnamed constants JAN = 1 FEB = 2 MAR = 3 APR = 4 MAY = 5 JUN = 6 JUL = 7 AUG = 8 SEP = 9 OCT = 10 NOV = 11 DEC = 12 # Entering Month separate from day: # Once month value is entered it cannot be changed month = -1 while (month < JAN) or (month > DEC): month = int(input("Enter value for month (1 - 12): ")) if (month < JAN) or (month > DEC): print("Month must be a value from 1 - 12") # Months with 31 days if (month in (JAN,MAR,MAY,JUL,AUG,OCT,DEC)): day = -1 while (day < 1) or (day > 31): day = int(input("Enter value for day (1 - 31): ")) if (day < 1) or (day > 31): print("Day must be a value from 1 - 31") # Months with 30 days elif (month in (APR,JUN,SEP,NOV)): day = -1 while (day < 1) or (day > 30): day = int(input("Enter value for day (1 - 30): ")) if (day < 1) or (day > 30): print("Day must be a value from 1 - 30") # Assume Feb always has 29 days elif (month == FEB): day = -1 while (day < 1) or (day > 29): day = int(input("Enter value for day (1 - 29): ")) if (day < 1) or (day > 29): print("Day must be a value from 1 - 29") print() print("Birth information") print("Birth month: %d" %month) print("Day of birth: %d" %day)