-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path26.py
More file actions
27 lines (22 loc) · 800 Bytes
/
26.py
File metadata and controls
27 lines (22 loc) · 800 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
26
27
Program No. : 31
Program : To check whether the year leap year or not.
def check_leap_year():
print("--- Leap Year Checker ---")
try:
# 1. Get the year from the user
year = int(input("Enter a year (e.g., 2024): "))
# 2. Apply Leap Year Logic
if (year % 4 == 0):
if (year % 100 == 0):
if (year % 400 == 0):
print(f"**{year}** is a Leap Year.")
else:
print(f"**{year}** is NOT a Leap Year.")
else:
print(f"**{year}** is a Leap Year.")
else:
print(f"**{year}** is NOT a Leap Year.")
except ValueError:
print("Error: Please enter a valid whole number for the year.")
# Run the function
check_leap_year()