Write a program that prompts the user to enter the month and
Write a program that prompts the user to enter the month and year and displays the number of days in the month. For example, if the user entered month 2 and year 2000, the program should display that February 2000 has 29 days. If the user entered month 3 and year 2005, the program should display that March 2005 has 31 days.
Solution
def IsLeap(year):
def findNumOfDays(month, year):
if month == 1 or month == 3 or month == 5 or month == 7 or month == 8 or month == 10 or month == 12:
return 31;
elif month == 4 or month == 6 or month == 9 or month == 11:
return 30
else:
if IsLeap(year):
return 29;
else:
return 28;
month = input(\'Enter the month: \')
m = [\'January\', \'February\', \'March\', \'April\', \'May\', \'June\', \'July\', \'August\', \'September\', \'October\', \'November\', \'December\']
year = input(\'Enter the year: \')
daysInAMonth = findNumOfDays(month, year)
return((not(year % 4) and year % 100) or not(year % 400))
print m[month-1], year, \'has\', daysInAMonth,\'days.\'
