Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python list for all months including leap years

# A function to determine if a year is a leap year.
# Do not change this function.
def is_leap_year(year):
    return (year % 4 == 0) and (year % 100 != 0) or (year % 400 == 0)

# You should complete the definition of this function:

def days_in_month(month, year):

    if month in ['September', 'April', 'June', 'November']:
        print 30

    elif month in ['January', 'March', 'May', 'July', 'August','October','December']:
        print 31        

    elif month == 'February' and is_leap_year(year) == True:
        print 29

    elif month == 'February' and is_leap_year(year) == False:
        print 28

    else:
        return None
Comment

PREVIOUS NEXT
Code Example
Python :: fibonacci series list comphrehension in python 
Python :: Converting Dataframe from the multi-dimensional list 
Python :: embed image in html from python 
Python :: uninstall python using powershell 
Python :: django prefetch_related vs select_related 
Python :: if name 
Python :: check regex in python 
Python :: remove new line character from string python 
Python :: pygame get keypress code 
Python :: Get Time from timestamp in python 
Python :: python 3.8.5 download 32 bit 
Python :: picasa 
Python :: finding odd even python 
Python :: python if condition assignment in one line 
Python :: play video in colab 
Python :: make the first letter of a string upper case 
Python :: square root in python 
Python :: python array usage 
Python :: python filter timestamp 
Python :: python json web request 
Python :: python 7zip extract 
Python :: get requests python 
Python :: Custom x, y-ticks using plt 
Python :: how to concatenate a string with int in python 
Python :: group by, aggregate multiple column -pandas 
Python :: jupyter notebook plot background dark theme 
Python :: python Modulo 10^9+7 (1000000007) 
Python :: Exception Value: Object of type User is not JSON serializable 
Python :: python numpy matrix to list 
Python :: how to concatenate dataframe in python 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =