Answer to Question #309932 in Python for big eddy

Question #309932

Write a function daysInMonth(month, year) 

The function receives two integers: month as a first parameter and year as a second parameter. 

If month is a February, the function checks if the current year is a leap year to determine how many days February contains.  

For the remaining months year check up is not required. 

In order to find out whether the year is leap, use function that you defined for the  Problem 1 solution. 

If year is not provided, the default value 2022 should be assigned to the year automatically. 


1
Expert's answer
2022-03-12T18:05:35-0500
def daysInMonth(month, year=2022):
    list1 = ['september', 'april', 'june', 'november']
    list2 = ['january', 'march', 'may', 'july', 'august', 'october', 'december']
    if month.lower() == 'february':
        if year % 4 == 0:
            return 29
        else:
            return 28
    elif month.lower() in list1:
        return 30
    elif month.lower() in list2:
        return 31



daysInMonth('February')

28

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS