Problem: Write a program in python to check whether a year is a leap year or not.
Input: 2020 Output: Leap Year Input: 2021 Output: Not a Leap Year
A year is said to be a leap year if it is divisible by 4. It mostly occurs every 4 years but every 100 years we skip a leap year unless it is divisible by 400.
Hence important point to note is that every year which is divisible by 4 is not necessarily a leap year, if the year is divisible by 100 then it should be divisible by 400 to be called a leap year.
Let’s write code in python to check leap year.
Recommended: If else in Python
year = int(input("Enter year: ")) if year%4==0 and year%100 != 0: print("Leap Year") elif year%400 == 0: print("Leap Year") else: print("Not a Leap Year")
Enter year: 2020