Determining Leap Years

So, it turns out your classmate was correct.  The reference that I used in class for determining whether a year is a leap year was incorrect.  The article found here gives the correct rules for determining a leap year.  You can read it on your own for more information.

In any case, I have written an accurate version of the program we were intending to implement that does correctly decide if a year is a leap year.  Please use this code to update your program.

# leapyear.py

# Rules for a leap year (see: http://www.infoplease.com/spot/leapyear2.html)

# 1. Most years that can be divided evenly by 4 are leap years.
#    (For example, 2012 divided by 4 = 503: Leap year!)

# 2. Exception: Century years are NOT leap years UNLESS they can be evenly 
#    divided by 400. (For example, 1700, 1800, and 1900 were not leap years, 
#    but 1600 and 2000, which are divisible by 400, were.)

# Note: Including \n in a string inserts a new (blank) line in the display.

print('\n********************')
print('Leap Year Calculator')
print('********************')

print('This program will tell you if the year you enter is a leap year.')

yearstr = raw_input('Enter a year: ')

year = int(yearstr)

# First check to see if your year is not divisible by 100 but divisible by 4.
if year % 100 != 0 and year % 4 == 0:
	# Yes
	print('Yes, ' + yearstr + ' is a leapyear.')

# Now check to see if your year is divisible by 100 and 400.
elif year % 100 ==0 and year % 400 == 0:
	# Also Yes
	print('Yes, ' + yearstr + ' is a leapyear.')

# Otherwise, it is not a leap year.
else:
	print('No, ' + yearstr + ' is not a leap year.')

print('\nDone.')