PYTHON ONLY Write a program that prompts the user to enter t

PYTHON ONLY

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 days(m,y):
    a=[31,28,31,30,31,30,31,31,30,31,30,31]#setting month values
    if(m==2):
        if(y%4==0):#if leap year returning 29 days..
            return 29
    return a[m-1]
def month(m):
   a=[\'January\',\'February\',\'March\',\'April\',\'May\',\'June\',\'July\',\'August\',\'September\',\'October\',\'November\',\'December\']
   return a[m-1]

m=input(\"Enter month:\")
y=input(\"Enter year:\")
print (month(m),\' \',y,\' has \',days(m,y),\' days.\')

ouput:

Enter month:2

Enter year:3

February 2000 has 29 days.

PYTHON ONLY 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 mon

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site