Write a program that prompts the user to input a year and determines whether the year is a leap year or not. Leap years are any years that can be evenly divided by 4. A year that is evenly divisible by 100 is a leap year only if it is also evenly divisible by 400.
Source Code
# Prompt the user to input a year
year = int(input("Enter a year(yyyy): "))
# Check if the year is a leap year and output the result
if year % 4 == 0:
if year % 100 != 0:
print(year, "is a leap year.")
elif year % 400 == 0:
print(year, "is a leap year.")
else:
print(year, "is not a leap year.")
else:
print(year, "is not a leap year.")
Output
Enter a year(yyyy): 2100
2100 is not a leap year.