Answers for "Given a month - an integer from 1 to 12, print the number of days in it in the year 2017."

0

Given a month - an integer from 1 to 12, print the number of days in it in the year 2017.

month = int (input ('month (1-12): '))

if month < 13:
    if month == 2:
        year = int (input ('year: '))
        if year % 4 == 0:
            if year % 100 == 0:
                if year % 400 == 0:
                    print ('29')
                else:
                    print ('28')
            else:
                print ('29')
        else:
            print ('28')

    elif month >= 8:
        if month % 2 == 0:
            print ('31')
        else:
            print ('30')

    elif month % 2 == 0:
        print ('30')
    else:
        print ('31')

else:
    print ('Only 1-12 accepted')
Posted by: Guest on August-07-2020

Code answers related to "Given a month - an integer from 1 to 12, print the number of days in it in the year 2017."

Browse Popular Code Answers by Language