Exercise 1: Check Leap Year
Write a method that takes a year as input and determines whether it’s a leap year.
We'll cover the following
Problem statement
Write a leap_year?
method that takes a year (a number), and determines if it’s a leap year.
Example
leap_year?(2000)
leap_year?(2020)
leap_year?(2022)
leap_year?(2100)
This should print out:
true
true
false
false
Recall that a leap year meets two qualifications:
- It’s divisible by four.
- It’s not divisible by 100 unless it’s divisible by 400.
Note: You just need to provide the definition of the method, and it will be automatically evaluated on the given input value.
Try it yourself
# Start your code here