Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to calculate leap year in python with function

#Leap year calculator
print('Leap year calculator')
print('>>>')
#=======================================
def is_leap_year(year):
  if (year % 400 == 0) and (year % 100 == 0):
    print(str(year) + " is a leap year".format(year))
    return True
  elif (year % 4 ==0) and (year % 100 == 0):
    print(str(year) + " is a leap year".format(year))
    return True
  else:
    print(str(year) + " is not leap year")
    return False
#=======================================
#input here
#            V  (insert year in ())
is_leap_year(2000)
#=========================================================
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #calculate #leap #year #python #function
ADD COMMENT
Topic
Name
4+9 =