In this python basic program, we will check whether the given year is a leap year or not.
Steps to solve the program
- Take a year as input through the user.
- Use the following condition to check whether the given year is a leap year or not – (year%400 == 0 or year%100 != 0) and year%4 == 0.
- Print the respective output.
year = int(input("Enter a year: "))
if (year%400 == 0 or year%100 != 0) and year%4 == 0:
print(f"{year} is a leap year")
else:
print(f"{year} is not a leap year")
Output :
Enter a year: 1700
1700 is not a leap year