-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLeapYear.py
More file actions
25 lines (23 loc) · 752 Bytes
/
LeapYear.py
File metadata and controls
25 lines (23 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'''
Find if the input year is a leap year or not.
The year must be divisible by both 100 AND 400 to be a leap year, or
if it is not divisible by 100, it must be divisible by 4.
Print a message telling the user if it is leap year or not.
'''
# ---Constants
HUNDRED = 100
FOURH = 400
FOUR = 4
# ---Input
year = int(input("Enter a year: "))
# ---Calculation and Output
if (year % HUNDRED) == 0:
if (year % FOURH) == 0:
print(year, " is a leap year. February has 29 days")
else:
print(year, " is not a leap year. February has 28 days")
else:
if (year % FOUR) == 0:
print(year, " is a leap year. February has 29 days")
else:
print(year, " is not a leap year. February has 28 days")