Skip to content

Instantly share code, notes, and snippets.

@lyntco
Last active August 29, 2015 14:07
Show Gist options
  • Save lyntco/c4d764931f7b90215819 to your computer and use it in GitHub Desktop.
Save lyntco/c4d764931f7b90215819 to your computer and use it in GitHub Desktop.
QUIZ-1 Leap year

Quiz-1 Leap Year


Write a program that will tell you whether a year is a leap year.

A leap year is a year divisible by 4 unless it is also divisible by 100. If the year is divisible by 400, it is a leap year.

leap_year?(1840) # => true
leap_year?(1989) # => false
leap_year?(2000) # => true
leap_year?(2014) # => false
leap_year?(2016) # => true

Extension


Add another method to output a human readable string.

leap_year_sentence(1989) # => "The year 1989 is not a leap year."
leap_year_sentence(2000) # => "The year 2000 is a leap year."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment