# Leap Year checker : If « Language Basics « Python

Home
Python
 1 2D 2 Application 3 Buildin Function 4 Class 5 Data Structure 6 Data Type 7 Database 8 Development 9 Dictionary 10 Event 11 Exception 12 File 13 Function 14 GUI Pmw 15 GUI Tk 16 Language Basics 17 List 18 Math 19 Network 20 String 21 System 22 Thread 23 Tuple 24 Utility 25 XML
 Python » Language Basics » If Screenshots
Leap Year checker
 ``` import sys import string def julian_leap(y=2000):     if (y%4) == 0:         return 1     return 0 def gregorian_leap(y=2000):     if (y%400) == 0:          return 1     elif (y%100) == 0:          return 0     elif (y%4) == 0:          return 1     return 0  years = [1999,2000,2001,1900]  print julian_leap()  print gregorian_leap()  if julian_leap():      print "Julian 2000 yes"  if gregorian_leap():      print "Gregorian 2000 yes"  for x in years:      if julian_leap(x):          print "Julian", x, "is leap"      else:          print "Julian", x, "is not leap"      if gregorian_leap(x):          print "Gregorian", x, "is leap"      else:          print "Gregorian", x, "is not leap"                    ```
Related examples in the same category
 1 Nested if statement 2 if-else structure 3 if-elif-else structure 4 if structure 5 if Statements: if, elif and else 6 Boolean operation in if 7 elif demo 8 if with else 9 If statement: a dictionary-based 'switch'