February usually has 28 days . However, in a leap year, February has 29 days. Write a program that asks the user for the year number and then displays "Year xxxs is a leap year" or "Year xxxx is not a leap year", where xxxx is the year the user entered.
To determine whether a year is a leap year or not, follow these rules:
If a year is divisible by 100 and 400 then it is a leap year.
If a year is not divisible by 100 but divisible by 4, then it is a leap year.
Input Format
a year
Constraints
The year should be between 1 and the current year.
Output Format
Year xxxx is a leap year. or
Year xxxx is not a leap year.
Sample Input 0
2000
Sample Output 0
Enter the year: Year 2000 is a leap year.
Sample Input 1
1900
Sample Output 1
Enter the year: Year 1900 is not a leap year.
Sample Input 2
2008
Sample Output 2
Enter the year: Year 2008 is a leap year.
Sample Input 3
2010
Sample Output 3
Enter the year: Year 2010 is not a leap year.
Sample Input 4
0
Sample Output 4
Enter the year: invalid year. Exiting.
Sample Input 5
3000
Sample Output 5
Enter the year: invalid year. Exiting.
Sample Input 6
one hundred
Sample Output 6
Enter the year: invalid year. Year must be a whole number.
Sample Input 7
2000.67
Sample Output 7
Enter the year: invalid year. Year must be a whole number.
Submissions:
43
Max Score:
10
Difficulty:
Medium
Rate This Challenge:
More
Python 3
1