Answer:
The program in python is as follows
Because of the length of the program, it'll be better to use comments to replace the explanation section; So, read through the comments too
See Attachment from source file (as jpg)
#Initialize list of Valid Months
validmonths = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]
#Initialize number of days in each months
days = [30,28,31,30,31,30,31,31,30,31,30,31]
check = 0 #Initialize a variable to check if month is valid is or not
year = int(input("Enter a year: ")) #Prompt user for year
month = input("Enter a month: ") #Prompt user for month
for i in range(12): #Iterate through list of valid months to check if user input is valid or not
if month == validmonths[i]:
check = i+1
#Check if the declared variable is still 0; If yes, then month is invalid
if check == 0:
print(month+" is not a correct month")
#Otherwise month is valid
else:
if not(month == "Feb"): #If month is not Feb, print corresponding number of days
print(month + " " +str(year) +" has "+str(days[check-1])+" days")
else: #Otherwise, if month is Feb, then there's a need to check for leap year using the following if statements
if year%4 == 0:
if year%100 == 0:
if year%400 == 0:
print(month + " " + str(year)+ " has 29 days")
else:
print(month + " " + str(year)+ " has 28 days")
else:
print(month + " " + str(year)+ " has 29 days")
else:
print(month + " " + str(year)+ " has 28 days")
Step-by-step explanation: