PYTHON PROGRAM TO CHECK LEAP YEAR (EXPLAINED SIMPLY)

Python Program to Check Leap Year (Explained Simply)

Python Program to Check Leap Year (Explained Simply)

Blog Article

Want to check if a year is a leap year program in Python? Here's the logic:


A year is a leap year if:





  • It's divisible by 4, and




  • Not divisible by 100, unless also divisible by 400.





python






year = int(input("Enter a year: ")) if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0): print("Leap Year") else: print("Not a Leap Year")


This simple conditional check covers all edge cases — even years like 2000 (leap) and 1900 (not leap). Practice this to understand logical operators and conditionals in Python.

Report this page