Python Program to Check Given Year is Leap Year or Not
The following example shows, how to check whether given year is Leap or Not.
Steps
- Get the year as ainput from user.
- If a year is divisible by 4 or 400, it is a leap year.
- If that year is divisible by 100, it is not a leap year,
Here the Example Check the given year is Leap year or Not using if,else statement.
Example.py
year = int(input("Enter the Year : ")) if (year%400 == 0) or (year%4==0 and year%100!=0): print("Leap Year") else: print("Not a Leap Year")
Output 1
Enter the Year : 2024 Leap Year
Output 2
Enter the Year : 2001 Not a Leap Year